#[Taxonomy]

Attribute on classes.

use Saij\WpAppFramework\Post\Taxonomy;

Declares a taxonomy on a class without constructor parameters (term meta comes later). The framework registers it as {namespace}_{name}, always shown in the REST API, so the block editor offers it for its post types.

Arguments

#[Taxonomy(string $name, string $label, string $singularLabel, array $postTypes, ?TaxonomyLabels $labels = null, string $description = '', bool $public = true, bool $showUi = true, bool $hierarchical = false, ?string $slug = null)]
ParameterTypeDefaultDescription
namestringrequiredName without namespace: lowercase letters, digits and "_", starting with a letter; the full name has at most 32 characters.
labelstringrequiredPlural name, e.g. "Genres".
singularLabelstringrequiredSingular name, e.g. "Genre".
postTypeslist<class-string<AbstractPost>>requiredPost classes of the taxonomy: classes with #[PostType], Post or Page.
labelsTaxonomyLabels|nullnullFurther labels; null derives all of them from the names in English.
descriptionstring''Description of the taxonomy.
publicbooltrueThe taxonomy is shown on the front end (archives of its terms) and in the admin; WordPress' public argument.
showUibooltrueThe admin shows screens to manage its terms.
hierarchicalboolfalseTerms have parents, like categories; otherwise flat, like tags.
slugstring|nullnullURL slug; null uses the name with "-" instead of "_".