Why is WordPress custom post type not showing in admin panel?

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.

Related posts

4 comments

  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
    
  2. 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

  3. 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).

Comments are closed.