Custom Post Type With Categories

I have copied custom post type code from WordPress and modified and added to function.php but Where is the categories box. I cant seen anywhere. I want also for this post.

I want to see this in my post

Read More

I am not good for WordPress So please guide me to solve this issue.

Thanks 🙂

My Code:

function codex_custom_init() {
  $labels = array(
    'name'               => 'Prices',
    'singular_name'      => 'Price',
    'add_new'            => 'Add New',
    'add_new_item'       => 'Add New Price',
    'edit_item'          => 'Edit Price',
    'new_item'           => 'New Price',
    'all_items'          => 'All Prices',
    'view_item'          => 'View Price',
    'search_items'       => 'Search Prices',
    'not_found'          => 'No prices found',
    'not_found_in_trash' => 'No prices found in Trash',
    'parent_item_colon'  => '',
    'menu_name'          => 'Prices'
  );

  $args = array(
    'labels'             => $labels,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'price' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => null,
    'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
  );

  register_post_type( 'price', $args );
}
add_action( 'init', 'codex_custom_init' );

Related posts

1 comment

  1. Hey Manan try this code:

    function codex_custom_init() {
      $labels = array(
        'name'               => 'Prices',
        'singular_name'      => 'Price',
        'add_new'            => 'Add New',
        'add_new_item'       => 'Add New Price',
        'edit_item'          => 'Edit Price',
        'new_item'           => 'New Price',
        'all_items'          => 'All Prices',
        'view_item'          => 'View Price',
        'search_items'       => 'Search Prices',
        'not_found'          => 'No prices found',
        'not_found_in_trash' => 'No prices found in Trash',
        'parent_item_colon'  => '',
        'menu_name'          => 'Prices'
      );
    
      $args = array(
        'labels'             => $labels,
        'public'             => true,
        'publicly_queryable' => true,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'query_var'          => true,
        'rewrite'            => array( 'slug' => 'price' ),
        'capability_type'    => 'post',
        'has_archive'        => true,
        'hierarchical'       => false,
        'menu_position'      => null,
        'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
        'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
      );
    
      register_post_type( 'price', $args );
      register_taxonomy_for_object_type('category', 'price');
    }
    add_action( 'init', 'codex_custom_init' );
    

Comments are closed.