Create a Taxonomy
Taxonomies are created using the Taxonomy
class. This works identically to the PostType
class and holds similar methods.
Create a new taxonomy
To create a new taxonomy pass the taxonomy name to the class constructor. Labels and the slug are generated from the taxonomy name.
Set names
You can define names by passing an array as the first argument. Only name
is required.
The following names are accepted.
Add options
You can further customise taxonomies by passing an array of options as the second argument in the constructor.
Alternatively, you can set options using the options()
method.
The options match the arguments passed to the register_taxonomy()
WordPress function. All available options are on the WordPress Codex.
Add labels
You can define the labels for a taxonomy by passing an array as the third argument in the class constructor.
Alternatively, you can use the labels()
method to set the labels for the taxonomy.
All available labels are on the WordPress Codex
Work with existing Taxonomies
You can work with existing taxonomies by passing the taxonomy name to the Taxonoy constructor. Once you have made your changes you need to register them to WordPress using the register()
method.
Last updated