I noticed the click tags panel wont appear with custom post types. I have a post type called portfolio and I would like to have the click tags panel.
Thank you.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI noticed the click tags panel wont appear with custom post types. I have a post type called portfolio and I would like to have the click tags panel.
Thank you.
You have to register the post_tag
taxonomy for your post type:
<?php
register_taxonomy_for_object_type( 'post_tag', 'portfolio' );
Now you've got post_tag
taxonomy shared with regular posts and other post types for which tags where registered.
If you want to use custom taxonomy for example, portfolio-tag, which belongs to the portfolio custom post type only:
<?php
function portfolio_tags()
{
$labels = array(
'name' => 'Portfolio Tag',
// More labels goes here
);
$args = array(
'labels' => $labels,
// More arguments goes here
);
// agrs: taxonomy key, custom post type, arguments
register_taxonomy( 'portfolio-tags', 'portfolio', $args );
}
add_action( 'init', 'portfolio_tags', 0 );
For register_taxonomy()
arguments see the Code Reference.