1

Every time I create a custom post type, the label never shows on the left admin panel, However, they do show when you click on manage post type.. Not sure what is going on.

3
  • 3
    manage post type? that's not something that's part of WordPress core, are you using a plugin to add post types?
    – Milo
    Nov 7 '13 at 4:05
  • Please post the code you are using to register your post type. Nov 7 '13 at 9:33
  • Make sure you don't give your post type a slug with more than 2 separators like this : custom_post_type, use custom_posttype instead.
    – Ari
    Dec 12 '14 at 18:04
2

Please check what the value of the show_in_menu and show_ui arguments for register_post_type your post types before you register tham.

1
  • Thank you Oleg, if ayone come here asking for a solution to hidden CPT in dashboard menu items,please take this into asscount (from codex): Default 'show_ui' value is value of $public., I just change the value of public and my item disappear!
    – Pedro
    May 31 at 21:10
1

Sometimes this can be caused by the menu_position clashing with another menu position, or perhaps being hidden away by some other plugin. Try changing that value.

'menu_position' => 21
0

Hi I Have Some Idea Add I Also Create Custom Post Type You Need Custome Post Type You Follow This Code It's Work for me.

// Register Custom Post Type services
function create_services_cpt() {

    $labels = array(
        'name' => _x( 'services', 'Post Type General Name', 'e-education' ),
        'singular_name' => _x( 'services', 'Post Type Singular Name', 'e-education' ),
        'menu_name' => _x( 'services', 'Admin Menu text', 'e-education' ),
        'name_admin_bar' => _x( 'services', 'Add New on Toolbar', 'e-education' ),
        'archives' => __( 'services Archives', 'e-education' ),
        'attributes' => __( 'services Attributes', 'e-education' ),
        'parent_item_colon' => __( 'Parent services:', 'e-education' ),
        'all_items' => __( 'All services', 'e-education' ),
        'add_new_item' => __( 'Add New services', 'e-education' ),
        'add_new' => __( 'Add New', 'e-education' ),
        'new_item' => __( 'New services', 'e-education' ),
        'edit_item' => __( 'Edit services', 'e-education' ),
        'update_item' => __( 'Update services', 'e-education' ),
        'view_item' => __( 'View services', 'e-education' ),
        'view_items' => __( 'View services', 'e-education' ),
        'search_items' => __( 'Search services', 'e-education' ),
        'not_found' => __( 'Not found', 'e-education' ),
        'not_found_in_trash' => __( 'Not found in Trash', 'e-education' ),
        'featured_image' => __( 'Featured Image', 'e-education' ),
        'set_featured_image' => __( 'Set featured image', 'e-education' ),
        'remove_featured_image' => __( 'Remove featured image', 'e-education' ),
        'use_featured_image' => __( 'Use as featured image', 'e-education' ),
        'insert_into_item' => __( 'Insert into services', 'e-education' ),
        'uploaded_to_this_item' => __( 'Uploaded to this services', 'e-education' ),
        'items_list' => __( 'services list', 'e-education' ),
        'items_list_navigation' => __( 'services list navigation', 'e-education' ),
        'filter_items_list' => __( 'Filter services list', 'e-education' ),
    );
    $args = array(
        'label' => __( 'services', 'e-education' ),
        'description' => __( 'post display theme services', 'e-education' ),
        'labels' => $labels,
        'menu_icon' => 'dashicons-buddicons-buddypress-logo',
        'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'author', 'trackbacks', 'page-attributes', 'post-formats', 'custom-fields'),
        'taxonomies' => array(),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'show_in_admin_bar' => true,
        'show_in_nav_menus' => true,
        'can_export' => true,
        'has_archive' => true,
        'hierarchical' => true,
        'exclude_from_search' => true,
        'show_in_rest' => true,
        'rest_base' => 'true',
        'publicly_queryable' => true,
        'capability_type' => 'post',
    );
    register_post_type( 'services', $args );

}
add_action( 'init', 'create_services_cpt', 0 );

This code carefully use Services => is my custom Post Type e-education => is my 'text-domain' you replace and Use

1
  • There's an error in this code. rest_base is a string, not a bool, and rather than using 'true' as a value, the value is generally the post_type - in this case 'services'. Just because your code works for you doesn't mean your code is the answer to someone else's code not working. There was probably something else interfering with (perhaps) good code that the OP had. I'm struggling with this same situation now. Everything looks right. I need to look deeper to see what is affecting the left-hand navigation bar when the "+NEW" admin bar shows my CPT.
    – TonyG
    Oct 13 at 22:58
0

This is a very old Q&A but I just resolved this by ensuring that register_post_type is invoked in a callback on action 'init', not 'admin_init'.

I was thinking that since I would only want my CPT maintenance to be visible to admins that I should setup on admin_init. I believe the proper way to see this is that CPT dashboard menus are generated on 'init', and to limit the visibility, use capabilities. That is, set capabilities on the CPT and add capabilities to roles which are assigned to users. See this other SE Q&A on that topic.

You don't want to avoid the registration code using is_admin. It's more likely that a CPT should always be defined for all users, and that we just want to restrict visibility and maintenance rights to specific users (via their capabilities).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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