-
Notifications
You must be signed in to change notification settings - Fork 5
taxonomy
simmontali edited this page Sep 10, 2019
·
2 revisions
Aeria defines taxonomies too. Taxonomies are WordPress' way to group things. An example of taxonomy are WP's categories, or its post tags.
Let's define Aeria's 3 main fields:
-
"name"
defines the name for this taxonomy. It must not exceed 32 characters. -
"kind"
defines the type of configuration: we're gonna set it to "taxonomy" this time. -
"spec"
defines the specific configurations for this taxonomy.
{
"name": "book-categories",
"spec": {},
"kind": "taxonomy"
}
If you want to leave this configuration disabled for now, you can add "enabled": false
to these fields.
Now let's specify where we want the taxonomy to be used, and the arguments for it.
-
"object_type"
is an array defining what the taxonomy can contain. Since we're talking about books, we're gonna set it to "book" only. -
"args"
is an array containing the optional arguments for the taxonomy creation. To read a full list, check the WordPress Reference for taxonomies. We're gonna insert a label for the taxonomy, and some strings in the"labels"
array. You can find all the labels in the WordPress Reference for labels.
{
"object_type": ["book"],
"args": {
"label": "Book Categories",
"labels":[
"all_items": "All book categories",
"singular_name": "Book category"
]
}
}
Our config file is now ready and looks like this:
{
"name": "book-categories",
"spec": {
"object_type": ["book"],
"args": {
"label": "Book Categories",
"labels":[
"all_items": "All book categories",
"singular_name": "Book category",
"add_new_item": "Add new book category"
]
}
},
"kind": "taxonomy"
}