Plugin API Reference
Custom Taxonomies (TaxonomyRegistry)
Create custom grouping systems (categories, tags, etc.) that can be attached to any registered post type.
📍 Source: App\CMS\Taxonomies\TaxonomyRegistry
Registering a Taxonomy
use App\CMS\Taxonomies\TaxonomyRegistry;
public function boot(): void
{
TaxonomyRegistry::register('announcement_category', [
'label' => 'Announcement Categories',
'singular' => 'Category',
'post_types' => ['announcement'],
'hierarchical'=> true, // true = categories, false = tags
]);
}
Method Signature
TaxonomyRegistry::register(string $slug, array $options): void
Options Reference
| Key | Type | Default | Description |
|---|---|---|---|
label | string | slug (ucfirst) | Plural display name |
singular | string | label | Singular display name |
post_types | array | ['post'] | Post type slugs this taxonomy attaches to |
hierarchical | bool | false | true = tree (categories), false = flat (tags) |
public | bool | true | Whether this taxonomy is publicly accessible |
Assigning Terms to Posts
// Assign taxonomy terms to a post
$post->taxonomies()->attach($termId, ['taxonomy' => 'announcement_category']);
// Query posts by taxonomy term
$posts = Post::whereHas('taxonomies', function ($q) {
$q->where('taxonomy', 'announcement_category')
->where('slug', 'urgent');
})->get();
Hierarchical vs Flat
Hierarchical (Categories)
Tree structure with parent-child relationships. Shows as checkbox UI in admin. Set hierarchical: true.
Flat (Tags)
Simple flat list. Shows as tag input UI in admin. Set hierarchical: false (default).
Last verified against AIPostify core. © 2026 AIPostify Marketplace Developer Documentation.