1 2 3 4 5 6 7 8 9 10 |
register_taxonomy( 'internal_name', 'object_type', array( 'hierarchical' => {true|false}, 'label' => 'Readable Name', 'query_var' => {true|false}, 'rewrite' => {true|false} ) ); |
- internal_name: What will this taxonomy be called from inside WordPress, in the database and template files?
- object_type: Which types of content can be classified with this taxonomy? Possible values are “post, page, link,” and then names of custom post types we’ll learn to create in a future tutorial.
- Next comes an array of optional parameters. We’ll use the most important ones here in this tutorial, but a full list can be found on the Function Reference / register_taxonomy Codex page. The parameters we’ll use are:
- hierarchical: If ‘true,’ this taxonomy has hierarchical abilities like WordPress Categories. If ‘false,’ this taxonomy behaves much like freeform Tags.
- label: This is the human-readable name used in your site’s interface to label the taxonomy.
- query_var: If ‘true,’ we’ll be able to ask WordPress for posts dependent upon the selections for this taxonomy. For example, we could search for all the posts where the operating system taxonomy has ‘Windows’ selected.
- rewrite: If ‘true,’ WordPress will use friendly URL’s when viewing a page for this taxonomy.