Skip to content
Advertisement

show category and tags when using register_post_type

So i used register_post_type to add books post_type section.

But i want to show category and tags(and more) on the back panel edit.php.

I know how to this(adding custom fields) in regular post.

add_action( 'init', 'bookworm_blog_cpt' );

function bookworm_blog_cpt() {

    register_post_type( 'book', array(
      'labels' => array(
        'name' => 'Books',
        'singular_name' => 'Book',
       ),
      'description' => 'Books which we will be discussing on this blog.',
      'public' => true,
      'menu_position' => 20,
      'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields' )
    ));
    
}

image illustration: enter image description here i searched for a solution all over the web but didn’t find.

Advertisement

Answer

You need to use hooks to add custom columns to the post type index, there is 3 or 4 hooks you need to use so posting an example here would be slightly long winded and probably more confusing.

This article covers the subject: http://justintadlock.com/archives/2011/06/27/custom-columns-for-custom-post-types

If you don’t wish to use that tutorial, you can just Google ‘add custom column to custom post type index’ and you’ll have plenty to choose from. Hope that helps set you on the right path.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement