How to Add Tag Selection to Custom Post Type

Snippets by IsItWP

Are you looking for a way to enable tag selection within the editor for that custom post type? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add tag selection to custom post type in WordPress.


All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function reg_tag() {
	 register_taxonomy_for_object_type('post_tag', 'CUSTOM_POST_TYPE');
add_action('init', 'reg_tag');

Don’t forget to change the CUSTOM_POST_TYPE to the name of the custom post type you created.

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 23 best WordPress themes for non-profits and how to save partial form data in WordPress.

Comments  Leave a Reply

  1. Sorry I’m dumb, but this code adds tags to desired CPT, okay, but it adds already created tags I made for default Posts. How to adjust code so my CPT will have its own unique tags? Thank you!

  2. Titouan Pellerin August 1, 2019 at 8:55 pm

    Nice snippet. It saved me, thanks a lot !

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!