banner-image

Create custom taxonomy for ‘POST’

By default, ‘posts’ have a custom taxonomy called ‘categories’.

But what if we need a new custom taxonomy/category for default ‘post’.

To create a new custom taxonomy/category for the default post, we have to add the below function to the active theme’s functions.php file.

 

add_action( 'init', 'new_category_for_post' );

function new_category_for_post(){

  register_taxonomy(
    'post_new_categories', //register the taxonomy/category
    'post',
    array(
      'label' => __( 'New Post Category' ), //name of the new category/taxonomy
      'rewrite' => array( 'slug' => 'new-post-category' ), //url of the new category/taxonomy
      'hierarchical' => true,
      'show_admin_column'=> true,
    )
  );
}

 

That’s it. Enjoy…

Do You Want To Boost Your Business?

drop us a line and keep in touch