Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
pollora-taxonomies
pollora-taxonomies
pollora/nectar
claude-code
taxonomies
wordpress
pollora
attributes
auto-discovery
custom-taxonomy

Create and configure WordPress custom taxonomies using Pollora PHP 8 attributes and the discovery system.

Install
php artisan boost:add-skill pollora/nectar

Save this content to: .claude/skills/pollora-taxonomies/SKILL.md

# Pollora Taxonomies Development

## When to use this skill
Use this skill when creating, modifying, or configuring WordPress custom taxonomies in a Pollora project.

## Creating a Taxonomy

Taxonomies are PHP classes with attributes. Place them in `app/Cms/Taxonomies/` in themes or `app/Models/` in modules.

### Basic Taxonomy

```php
<?php

namespace Theme\MyTheme\Cms\Taxonomies;

use Pollora\Attributes\Taxonomy\Taxonomy;
use Pollora\Attributes\Taxonomy\Hierarchical;
use Pollora\Attributes\PostType\ShowInRest;

#[Taxonomy('genre', objectType: 'book')]
#[Hierarchical]
#[ShowInRest]
class BookGenre
{
}
```

### Taxonomy with Custom Configuration

```php
#[Taxonomy('genre', objectType: 'book')]
#[Hierarchical]
#[ShowInRest]
class BookGenre
{
    public function configuring(\Pollora\Entity\Domain\Model\Taxonomy $taxonomy): void
    {
        $taxonomy->labels([
            'name' => __('Genres', 'my-theme'),
            'singular_name' => __('Genre', 'my-theme'),
            'search_items' => __('Search Genres', 'my-theme'),
        ]);
        $taxonomy->rewrite(['slug' => 'genres']);
    }

    public function withArgs(): array
    {
        return [
            'description' => 'Book genres for the library',
        ];
    }
}
```

### Multiple Object Types

Associate a taxonomy with multiple post types:

```php
#[Taxonomy('genre', objectType: ['book', 'audiobook'])]
#[Hierarchical]
#[ShowInRest]
class Genre {}
```

### Available Attributes

| Attribute | Purpose | Example |
|-----------|---------|---------|
| `#[Taxonomy('slug', objectType: '...')]` | Register taxonomy | `#[Taxonomy('genre', objectType: 'book')]` |
| `#[Hierarchical]` | Category-like (vs tag-like) | `#[Hierarchical]` |
| `#[ShowInRest]` | Enable in block editor + REST API | `#[ShowInRest]` |
| `#[Labels(...)]` | Override specific labels | `#[Labels(addNew: 'Add Genre')]` |
| `#[AdminCols([...])]` | Custom admin columns | `#[AdminCols([...])]` |
| `#[Priority(n)]` | Registration order | `#[Priority(10)]` |

### Tag-like (Non-Hierarchical) Taxonomy

```php
#[Taxonomy('tag', objectType: 'book')]
#[ShowInRest]
class BookTag
{
    // Non-hierarchical by default (tag-like behavior)
}
```

### Important Notes

- **Auto-discovered** — no manual `register_taxonomy()` calls needed
- Run `php artisan discovery:clear` after creating a new taxonomy class
- The `objectType` parameter links the taxonomy to one or more post types
- Labels are auto-generated from the class name if not specified
- Use `configuring()` for translatable labels and custom rewrite rules

Pollora Taxonomies Development

When to use this skill

Use this skill when creating, modifying, or configuring WordPress custom taxonomies in a Pollora project.

Creating a Taxonomy

Taxonomies are PHP classes with attributes. Place them in app/Cms/Taxonomies/ in themes or app/Models/ in modules.

Basic Taxonomy

<?php

namespace Theme\MyTheme\Cms\Taxonomies;

use Pollora\Attributes\Taxonomy\Taxonomy;
use Pollora\Attributes\Taxonomy\Hierarchical;
use Pollora\Attributes\PostType\ShowInRest;

#[Taxonomy('genre', objectType: 'book')]
#[Hierarchical]
#[ShowInRest]
class BookGenre
{
}

Taxonomy with Custom Configuration

#[Taxonomy('genre', objectType: 'book')]
#[Hierarchical]
#[ShowInRest]
class BookGenre
{
    public function configuring(\Pollora\Entity\Domain\Model\Taxonomy $taxonomy): void
    {
        $taxonomy->labels([
            'name' => __('Genres', 'my-theme'),
            'singular_name' => __('Genre', 'my-theme'),
            'search_items' => __('Search Genres', 'my-theme'),
        ]);
        $taxonomy->rewrite(['slug' => 'genres']);
    }

    public function withArgs(): array
    {
        return [
            'description' => 'Book genres for the library',
        ];
    }
}

Multiple Object Types

Associate a taxonomy with multiple post types:

#[Taxonomy('genre', objectType: ['book', 'audiobook'])]
#[Hierarchical]
#[ShowInRest]
class Genre {}

Available Attributes

Attribute Purpose Example
#[Taxonomy('slug', objectType: '...')] Register taxonomy #[Taxonomy('genre', objectType: 'book')]
#[Hierarchical] Category-like (vs tag-like) #[Hierarchical]
#[ShowInRest] Enable in block editor + REST API #[ShowInRest]
#[Labels(...)] Override specific labels #[Labels(addNew: 'Add Genre')]
#[AdminCols([...])] Custom admin columns #[AdminCols([...])]
#[Priority(n)] Registration order #[Priority(10)]

Tag-like (Non-Hierarchical) Taxonomy

#[Taxonomy('tag', objectType: 'book')]
#[ShowInRest]
class BookTag
{
    // Non-hierarchical by default (tag-like behavior)
}

Important Notes

  • Auto-discovered — no manual register_taxonomy() calls needed
  • Run php artisan discovery:clear after creating a new taxonomy class
  • The objectType parameter links the taxonomy to one or more post types
  • Labels are auto-generated from the class name if not specified
  • Use configuring() for translatable labels and custom rewrite rules
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource