Add Tags to Custom Post Type

If you need to add Tags to your Custom Post Type, use the following snippet.

Place in your functions.php file where your Post Type is initialized.

'taxonomies' => array('post_tag')

Full Code:

$labels = array(
	'name' => _x('Speakers', 'post type general name'),
	'singular_name' => _x('Speaker', 'post type singular name'),
	'add_new' => _x('Add New Speaker', 'Speaker'),
	'add_new_item' => __('Add New Speaker'),
	'edit_item' => __('Edit Speaker'),
	'new_item' => __('New Speaker'),
	'all_items' => __('All Speakers'),
	'view_item' => __('View Speaker'),
	'search_items' => __('Search Speakers'),
	'not_found' =>  __('No Speakers found'),
	'not_found_in_trash' => __('No Speakers found in Trash'), 
	'parent_item_colon' => '',
	'menu_name' => __('Speakers')
);
$args = array(
	'labels' => $labels,
	'public' => true,
	'publicly_queryable' => true,
	'show_ui' => true, 
	'show_in_menu' => true, 
	'query_var' => true,
	'rewrite' => true,
	'capability_type' => 'post',
	'has_archive' => true, 
	'hierarchical' => false,
	'menu_position' => null,
	'supports' => array( 'title', 'revisions', 'thumbnail', 'editor', 'tags' ),
	'exclude_from_search' => false,
	'taxonomies' => array('post_tag'), // add the above line here
); 
register_post_type('speaker',$args);

Source.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.