taxonomies.json
This file is responsible for registering custom taxonomies in PorterWP.
Structure
The taxonomies.json
file follows a simple structure where you define your taxonomies and the associated object types (post types) that will use them.
Example
An example of a basic taxonomy definition might look like this:
This defines a taxonomy called "Archive Topic," which is hierarchical (like categories), and it is attached to multiple post types including post
, event
, and more.
Hierarchical and Non-Hierarchical Taxonomies
Taxonomies can either be hierarchical (like WordPress categories) or non-hierarchical (like tags). The hierarchical
setting determines whether the taxonomy behaves like a category (with parent-child relationships) or a tag.
For example:
Hierarchical (like categories)
Non-Hierarchical (like tags)
Labels
Like post types, PorterWP will try to auto-generate labels based on the taxonomy name, but you can override the labels by specifying the labels
object in your taxonomy definition.
Object Types
The object_type
field defines the post types that the taxonomy is associated with. For example, the following will associate the taxonomy event-type
with the post type event
:
Register New Taxonomies
To register a new taxonomy, simply add it to the taxonomies
object. For example, adding a new taxonomy called research-type
:
This would create a taxonomy called "Research Types" that can be used for the post type research
.
Modifying Supports
PorterWP also allows you to modify taxonomy support settings. If you override the default settings, remember to define all the necessary parameters as PorterWP will assume you want to set all options manually.
For example:
Conclusion
The taxonomies.json
file allows you to manage and register custom taxonomies efficiently. PorterWP simplifies the process while giving you the flexibility to adjust labels, hierarchies, and object types according to your needs.
Last updated