WP SITES

3095 Coded Tutorials & 297 Plugins

Use Categories and Tags With Your Custom Post Type

Once you create a custom post type, you can either:

  1. Add support for creating custom taxonomy types to your existing CPT code
  2. Or add support for categories and tags just like your regular posts

There’s at least 2 ways to enable categories and tags for custom post types.

You can include this line of PHP code in the code you use to register a custom post type:

'taxonomies' => array('category', 'post_tag'),

Or you can add a new function like this:

add_action('init', 'add_category_tags_to_cpt');
 function add_category_tags_to_cpt() {
    register_taxonomy_for_object_type('category', 'your-cpt-name');
    register_taxonomy_for_object_type('post_tag', 'your-cpt-name');
}

Either method will add meta boxes on Edit screens for both Categories and Tags to all your single CPT’s.

Related Tutorials

Was this helpful?

Yes
No
Thanks for your feedback!

Leave a Reply