Create custom taxonomy in wordpress

Wordpress Tutorials, WrodPress Programmatically

Create custom taxonomy in wordpress

Custom taxonomy in wordpress

WordPress taxonomy is a grouping mechanism for some posts like category, tags. The names for the different groupings in a taxonomy are known as terms. example i am having a bunch of animals and i need to group of animals by it’s characteristics so we can differentiate they by term. below is the best explanation for how to create custom taxonomy in wordpress.


WordPress comes with following default taxonomies

  • Category (slug is ‘category’)
  • Tag (slug is ‘post_tag’)
  • Link Category (slug is ‘link_category’)
  • Post Formats (slug is ‘post_format’)


Register custom taxonomies

WordPress use register_taxonomy ( $taxonomy, $obj_type, $args )  function for create new custom taxonomy and it’s easy expalin in below.


$taxonomy (string) (required) : Enter the name of taxonomy and it must be in lowercase letters.

$object_type (array/string) (required) : Name of the object type for taxonomy object.

$args (array/string) (optional) : An array of arguments.


Create a custom taxonomy manually in WordPress

For creating a custom taxonomy manually for that you add the following code in a functions.php file on your theme.

// Register Custom Taxonomy
function my_custom_taxonomy() {

	$labels = array(
		'name'                       => _x( 'Categories', 'Taxonomy General Name', 'text_domain' ),
		'singular_name'              => _x( 'Category', 'Taxonomy Singular Name', 'text_domain' ),
		'menu_name'                  => __( 'Category', 'text_domain' ),
		'all_items'                  => __( 'All Items', 'text_domain' ),
		'parent_item'                => __( 'Parent Item', 'text_domain' ),
		'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),
		'new_item_name'              => __( 'New Item Name', 'text_domain' ),
		'add_new_item'               => __( 'Add New Item', 'text_domain' ),
		'edit_item'                  => __( 'Edit Item', 'text_domain' ),
		'update_item'                => __( 'Update Item', 'text_domain' ),
		'view_item'                  => __( 'View Item', 'text_domain' ),
		'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),
		'add_or_remove_items'        => __( 'Add or remove items', 'text_domain' ),
		'choose_from_most_used'      => __( 'Choose from the most used', 'text_domain' ),
		'popular_items'              => __( 'Popular Items', 'text_domain' ),
		'search_items'               => __( 'Search Items', 'text_domain' ),
		'not_found'                  => __( 'Not Found', 'text_domain' ),
		'no_terms'                   => __( 'No items', 'text_domain' ),
		'items_list'                 => __( 'Items list', 'text_domain' ),
		'items_list_navigation'      => __( 'Items list navigation', 'text_domain' ),
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => false,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => true,
        /* movies is a custom post type name */
	register_taxonomy( 'taxonomy', array( 'movies' ), $args );

add_action( 'init', 'my_custom_taxonomy', 0 );

Then after custom taxonomy Category created when you see on the WordPress admin dashboard and below is the screenshot for admin side display menu inside Movies custom post type.

custom taxonomy



label (string)(optional): A descriptive name of the taxonomy.

labels (array)(optional): An array of labels for this custom taxonomy.

public (boolean)(optional):  Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users.

publicly_queryable (boolean)(optional):  Whether the taxonomy is publicly queryable or not.

show_ui (boolean)(optional):  Whether to generate a default UI for managing this custom taxonomy.

show_in_menu (boolean)(optional):  Where to show taxonomy in the admin side menu.

show_in_nav_menus (boolean)(optional): If true then it makes this taxonomy available for selection in navigation menus.

show_in_rest (boolean)(optional):  Whether to include this taxonomy in the REST API or not.

rest_base (string)(optional):  To change the route of base url of REST API.

rest_controller_class (string)(optional):  name of the REST API Controller class.

show_tagcloud (boolean)(optional):  Whether to allow the tag cloud widget to use this taxonomy.

show_in_quick_edit (boolean)(optional):  Whether to show the taxonomy in the quick and bulk edit panel.

meta_box_cb (callback)(optional):  Provide a callback function name for the meta box display.

show_admin_column (boolean)(optional):  Whether to allow automatic creation of taxonomy columns on the associated post-types table.

description (string)(optional):  Description of the taxonomy.

hierarchical (boolean)(optional):  Is this taxonomy hierarchical like categories or not hierarchical like tags.

update_count_callback (string)(optional):  A function name that will be called when the count of an associated $object_type, such as post, is updated.

query_var (boolean or string)(optional):  False to disable the query_var, default is $taxonomy.

rewrite (boolean/array)(optional):  Set to false to prevent automatic URL rewriting.

capabilities (array)(optional):  An array of the capabilities for this taxonomy.

sort (boolean)(optional):  Whether this taxonomy should remember the order in which terms are added to objects.






12 thoughts on “Create custom taxonomy in wordpress

  1. I wanted to send you this very little note so as to thank you very much again for your personal pleasing basics you’ve contributed in this article. It is pretty generous with people like you to provide openly what a lot of people could have made available as an electronic book to earn some profit for themselves, most notably considering the fact that you might well have tried it in case you decided. Those good ideas as well served to become great way to comprehend the rest have similar desire the same as mine to see much more in regard to this issue. I think there are thousands of more pleasant occasions ahead for people who check out your website.

  2. Τhere are, of course, some adverse factors to freelancing.

    One important level is that in the event you work as a freelance paralegal youll
    not be eⅼigible for thе kinds of advantages that you would hаve in working for
    a reɡulɑtion agency or a personal attorney.
    If you feel that such “perks” as general healtһ insurance and
    other such advantages are important, freelancing wont give you these benefits.

  3. Eѵening family devotions were one of the crucial necessary parts of Lee and Larry?s day.
    Dadԁy read a part of the story of Jesus coming at Christmas which is the
    place he read еvery year during Decеmber so they might know the real reason for Chriѕtmas, to rejoice the beginning of Jesus.
    On the finish of it, Lee requested, ?Daddy, did Jеsus get a party
    every year ԝith ρresents and a clown too?

Leave a Reply