Developer Portal
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

KeyTypeDefaultDescription
labelstringslug (ucfirst)Plural display name
singularstringlabelSingular display name
post_typesarray['post']Post type slugs this taxonomy attaches to
hierarchicalboolfalsetrue = tree (categories), false = flat (tags)
publicbooltrueWhether 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.