Taxonomy
Adding Taxonomies to your project is as easy as adding Post Types.
$taxonomy = register_cuztom_taxonomy( $name, $post_type, $args );
$name
(string|array) Name of the Taxonomy. When using an array, the first element will be the name, the second will be the plural.
$post_type
(string|array) Post Type(s) to attach the Taxonomy to.
$args
(array) Arguments for the taxonomy. See here for the complete list of arguments.
Arguments
With Cuztom, you can pass some extra arguments to the Taxonomy object.
admin_column_sortable
Used to make a admin column sortable (show_admin_column must be true)
admin_column_filter
Used to make a admin column filterable (show_admin_column must be true)
Methods
Add Term Meta
You can use a method to add Term Meta. See the docs for more information. NOTE: Versions < 3.0 don't use Wordpress core functions to register and add Term Meta.
$taxonomy->add_term_meta( $data, $locations );
Examples
Taxonomy with admin columns
Add a taxonomy with sortable and filterable columns (in the Post Type table).
$genre = register_cuztom_taxonomy(
'Genre',
'book',
array(
'show_admin_column' => true,
'admin_column_sortable' => true,
'admin_column_filter' => true
)
);
Updated about 7 years ago