WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am add new post type called journal using below code it works fine. But I now I need to add a single category for this post type. That is I have two types of journal category normal journal and featured journals. But my blog post has some more categories I need to display only normal journal and featured journals on my journal list how can I do this. I am newbie in Wordpress coding. Thanks.

function post_type_journal()
        $args = array(
            'labels' => array(
                'name' => 'Journals',
                'singular_name' => 'Journal',
                'add_new' => 'Add new journal',
                'edit_item' => 'Edit journal',
                'new_item' => 'New journal',
                'view_item' => 'View journal',
                'search_items' => 'Search journal',
                'not_found' => 'No journals found',
                'not_found_in_trash' => 'No journals found in Trash'
            'public' => true,
            'supports' => array(
            'taxonomies' => array('category') // this is IMPORTANT
        register_post_type('Journal', $args);
share|improve this question
up vote 0 down vote accepted

You can add this line to the code which registers your Custom Post Type:

'taxonomies'   => array( 'category' ),

Or you could add Taxonomies rather than categories:

add_action( 'init', 'cpt_type_taxonomy' );
function cpt_type_taxonomy() {

register_taxonomy( 'portfolio-type', 'portfolio',
        'labels' => array(
            'name'          => _x( 'Types', 'taxonomy general name', 'theme' ),
            'add_new_item'  => __( 'Add New Portfolio Type', 'theme' ),
            'new_item_name' => __( 'New Portfolio Type', 'theme' ),
        'exclude_from_search' => true,
        'has_archive'         => true,
        'hierarchical'        => true,
        'rewrite'             => array( 'slug' => 'portfolio-type', 'with_front' => false ),
        'show_ui'             => true,
        'show_tagcloud'       => false,


Then add this line to the code which registers your Custom Post Type.

'taxonomies'   => array( 'portfolio-type' ),

Here's all the code which registers a Custom Post Type:

add_action( 'init', 'register_custom_post_type' );
function register_custom_post_type() {

register_post_type( 'portfolio',
        'labels' => array(
            'name'          => __( 'Portfolio', 'theme' ),
            'singular_name' => __( 'Portfolio', 'theme' ),
        'has_archive'  => true,
        'hierarchical' => true,
        'menu_icon'    => 'dashicons-icon-name',
        'public'       => true,
        'rewrite'      => array( 'slug' => 'portfolio', 'with_front' => false ),
        'supports'     => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes' ),
        'taxonomies'   => array( 'portfolio-type' ),


share|improve this answer

Categories are actually a "taxonomy" for the post post type, so you need to add a new taxonomy (eg 'People') for your Journal post type.


    function people_init() {
// create a new taxonomy
        'label' => __( 'People' ),
        'rewrite' => array( 'slug' => 'person' ),
        'capabilities' => array(
            'assign_terms' => 'edit_guides',
            'edit_terms' => 'publish_guides'
add_action( 'init', 'people_init' );

See here for more info on taxonomies.

share|improve this answer

Or you can use

<?php register_taxonomy_for_object_type( 'category', 'Journals' ); ?>

to map the categories to your custom post type.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.