post_tag taxonomy with custom post type

Enabling tags in a custom post type is quite simple. You need to use 'taxonomies' => array('post_tag') while calling register_post_type().

For Example:

register_post_type('movies',
        array(
            'labels' => array(
                'name'          =>  'Movies',
                'singular_name' =>  'Movie',
                'menu_name'     =>  'MOVIES',
                'all_items'     =>  'All Movies',
                'add_new'       =>  'Add A Movie',
                'add_new_item'  =>  'Add New Movie'
                ),
            'public'    => true,
            'supports'  => array(
                            'title',
                            'post-formats',
                            ),
            'show_in_admin_bar' =>  true,
            'taxonomies' => array('post_tag'),
            )
        );

Look for the last taxanomies => array('post_tag') in code. This is how you enable tags in a custom post type.

Leave a Comment