Taxonomy
Adding Taxonomies to your project is as easy as adding Post Types.
$taxonomy = new Cuztom_Taxonomy( $name, $post_type, $args, $labels );
$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.
$labels
(array) When not set, Cuztom will create them for you. Look here for the complete list.
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 = new Cuztom_Taxonomy(
'Genre',
'book',
array(
'show_admin_column' => true,
'admin_column_sortable' => true,
'admin_column_filter' => true
)
);
Updated over 8 years ago