How to Add Category Options for Custom Post Types

Adding category options for your custom post type is so easy. If you want your custom posts and the default posts to share the same categories, simply insert the ff. line of code below:

register_taxonomy_for_object_type('category', 'h-articles');

Where: h-articles is the id of your custom post type.

However, if you want to create a separate set of categories for our custom post type, simply add the ff. code snippet:

$args = array('label' => 'Categories', 'labels' => array('name' => 'Category', 'singular_name' => 'Category'), 'hierarchical' => true);
register_taxonomy('article-category', 'h-articles', $args);

Where: h-articles is the id of your custom post type.

Visit here for more options when creating a category option for your custom post type.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this pageEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *