How to add categories and tags option in custom post type in wordpress

How to add categories and tags option in custom post type.
Just copy and paste below code into your theme's functions.php

 function rj_register_post_type()
{
register_post_type('games',
    array(
    'description' => 'Game custom post type',
        'show_ui' => true,
        'exclude_from_search' => false,
        'labels' => array(
            'name' => 'Games',
            'singular_name' => 'Game',
            'add_new' => 'Add New Games',
            'add_new_item' => 'Add New Game',
            'edit' => 'Edit Games',
            'edit_item' => 'Edit Game',
            'new_item' => 'New Game',
            'view' => 'View Games',
            'view_item' => 'View Game',
            'search_items' => 'Search Games',
            'not_found' => 'No games found',
            'not_found_in_trash' => 'No games found in Trash',
            'parent' => 'Parent Game',
        ),
        'public' => true,
        'supports' => array('title','editor','revisions','thumbnail','author'),
        'taxonomies' => array('category', 'post_tag'),
        'rewrite' => array('slug' => 'games', 'with_front' => false),
        )
    );
}
add_action('init', 'rj_register_post_type');
add_action('init', 'rj_add_default_boxes');

function rj_add_default_boxes() {
    register_taxonomy_for_object_type('category', 'games');
    register_taxonomy_for_object_type('post_tag', 'games');
}


Comments

Popular posts from this blog

How to add image option in nav menu in wordpress

How to add a custom email functionality in woocommerce,wordpress for example new email template for shipping order

How to change user id on checkout page for assign order to different user in woocommerce wordpress