Newly created custom post type name is not showing up in wordpress dashboard - l

Support MB Custom Post Type Newly created custom post type name is not showing up in wordpress dashboard - lResolved

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #32967
    sharebiology@gmail.com[email protected]
    Participant

    Hello,

    The newly created custom post type name is not showing up in the WordPress dashboard - left sidebar. I have deactivated all plugins (except metabox and metabox AIO). still no luck. I am attaching a screenshot for reference.

    I have assigned the menu position after "fluorescent proteins". Fluorescent proteins is another CPT created a couple of years ago.

    one possible reason is I might have created CPT with this name years ago. Other than that I can not figure out what went wrong.

    https://sharebiology-gmail-com.nimbusweb.me/s/share/6459073/hp9vctddlltm3niwvm33

    #32971
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please try to re-save the permalink settings (Post name) to flush the cache and re-check the CPT.

    #32972
    sharebiology@gmail.com[email protected]
    Participant

    Hi,

    I did and it is not working
    any other solution?

    #32978
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Can you please share the code that creates the CPT? Refer to this documentation to get PHP code https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code

    #32998
    sharebiology@gmail.com[email protected]
    Participant

    Hello,

    Here is the code

    <?php
    add_action( 'init', 'your_prefix_register_post_type' );
    function your_prefix_register_post_type() {
        $labels = [
            'name'                     => esc_html__( 'Tissue clearing methods', 'your-textdomain' ),
            'singular_name'            => esc_html__( 'Tissue clearing method', 'your-textdomain' ),
            'add_new'                  => esc_html__( 'Add New', 'your-textdomain' ),
            'add_new_item'             => esc_html__( 'Add new tissue clearing method', 'your-textdomain' ),
            'edit_item'                => esc_html__( 'Edit Tissue clearing method', 'your-textdomain' ),
            'new_item'                 => esc_html__( 'New Tissue clearing method', 'your-textdomain' ),
            'view_item'                => esc_html__( 'View Tissue clearing method', 'your-textdomain' ),
            'view_items'               => esc_html__( 'View Tissue clearing methods', 'your-textdomain' ),
            'search_items'             => esc_html__( 'Search Tissue clearing methods', 'your-textdomain' ),
            'not_found'                => esc_html__( 'No tissue clearing methods found', 'your-textdomain' ),
            'not_found_in_trash'       => esc_html__( 'No tissue clearing methods found in Trash', 'your-textdomain' ),
            'parent_item_colon'        => esc_html__( 'Parent Tissue clearing method:', 'your-textdomain' ),
            'all_items'                => esc_html__( 'All Tissue clearing methods', 'your-textdomain' ),
            'archives'                 => esc_html__( 'Tissue clearing method Archives', 'your-textdomain' ),
            'attributes'               => esc_html__( 'Tissue clearing method Attributes', 'your-textdomain' ),
            'insert_into_item'         => esc_html__( 'Insert into tissue clearing method', 'your-textdomain' ),
            'uploaded_to_this_item'    => esc_html__( 'Uploaded to this tissue clearing method', 'your-textdomain' ),
            'featured_image'           => esc_html__( 'Featured image', 'your-textdomain' ),
            'set_featured_image'       => esc_html__( 'Set featured image', 'your-textdomain' ),
            'remove_featured_image'    => esc_html__( 'Remove featured image', 'your-textdomain' ),
            'use_featured_image'       => esc_html__( 'Use as featured image', 'your-textdomain' ),
            'menu_name'                => esc_html__( 'Tissue clearing methods', 'your-textdomain' ),
            'filter_items_list'        => esc_html__( 'Filter tissue clearing methods list', 'your-textdomain' ),
            'filter_by_date'           => esc_html__( '', 'your-textdomain' ),
            'items_list_navigation'    => esc_html__( 'Tissue clearing methods list navigation', 'your-textdomain' ),
            'items_list'               => esc_html__( 'Tissue clearing methods list', 'your-textdomain' ),
            'item_published'           => esc_html__( 'Tissue clearing method published', 'your-textdomain' ),
            'item_published_privately' => esc_html__( 'Tissue clearing method published privately', 'your-textdomain' ),
            'item_reverted_to_draft'   => esc_html__( 'Tissue clearing method reverted to draft', 'your-textdomain' ),
            'item_scheduled'           => esc_html__( 'Tissue clearing method scheduled', 'your-textdomain' ),
            'item_updated'             => esc_html__( 'Tissue clearing method updated', 'your-textdomain' ),
            'text_domain'              => esc_html__( 'your-textdomain', 'your-textdomain' ),
        ];
        $args = [
            'label'               => esc_html__( 'Tissue clearing methods', 'your-textdomain' ),
            'labels'              => $labels,
            'description'         => '',
            'public'              => true,
            'hierarchical'        => true,
            'exclude_from_search' => false,
            'publicly_queryable'  => true,
            'show_ui'             => true,
            'show_in_nav_menus'   => true,
            'show_in_admin_bar'   => true,
            'show_in_rest'        => true,
            'query_var'           => true,
            'can_export'          => true,
            'delete_with_user'    => false,
            'has_archive'         => false,
            'rest_base'           => '',
            'show_in_menu'        => true,
            'menu_position'       => '',
            'menu_icon'           => 'dashicons-carrot',
            'capability_type'     => 'post',
            'supports'            => ['title', 'editor', 'thumbnail', 'custom-fields'],
            'taxonomies'          => [],
            'rewrite'             => [
                'with_front' => false,
            ],
        ];
    register_post_type( 'tissue-clearing-method', $args );
    }
    #33006
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The post type slug must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores. Refer to this documentation https://developer.wordpress.org/reference/functions/register_post_type/

    The slug tissue-clearing-method has more than 20 characters. You can change it to something like tissue-clearing.

    #33013
    sharebiology@gmail.com[email protected]
    Participant

    Working now.

    Thanks 🙂

    #41348
    JordanJordan
    Participant

    Is there a way to increase the character limit in the URL? This is not good for our SEO, to choose less than 20 characters.

    #41358
    PeterPeter
    Moderator

    Hello Jordan,

    You can try to use the rewrite option to set the unlimited characters for CPT slug. It is not restricted by WordPress. Refer to the documentation https://developer.wordpress.org/reference/functions/register_post_type/#rewrite

    #41385
    VipinnVipinn
    Participant

    Same issue, newly created post type is not visible in the Dashboard menu. Here's the code:

    add_action( 'init', 'e78_register_post_type_cs' );
    function e78_register_post_type_cs() {
    	$labels = [
    		'name'                     => esc_html__( 'Case Studies', 'e78' ),
    		'singular_name'            => esc_html__( 'Case Study', 'e78' ),
    		'add_new'                  => esc_html__( 'Add New', 'e78' ),
    		'add_new_item'             => esc_html__( 'Add New Case Study', 'e78' ),
    		'edit_item'                => esc_html__( 'Edit Case Study', 'e78' ),
    		'new_item'                 => esc_html__( 'New Case Study', 'e78' ),
    		'view_item'                => esc_html__( 'View Case Study', 'e78' ),
    		'view_items'               => esc_html__( 'View Case Studies', 'e78' ),
    		'search_items'             => esc_html__( 'Search Case Studies', 'e78' ),
    		'not_found'                => esc_html__( 'No case studies found.', 'e78' ),
    		'not_found_in_trash'       => esc_html__( 'No case studies found in Trash.', 'e78' ),
    		'parent_item_colon'        => esc_html__( 'Parent Case Study:', 'e78' ),
    		'all_items'                => esc_html__( 'All Case Studies', 'e78' ),
    		'archives'                 => esc_html__( 'Case Study Archives', 'e78' ),
    		'attributes'               => esc_html__( 'Case Study Attributes', 'e78' ),
    		'insert_into_item'         => esc_html__( 'Insert into case study', 'e78' ),
    		'uploaded_to_this_item'    => esc_html__( 'Uploaded to this case study', 'e78' ),
    		'featured_image'           => esc_html__( 'Featured image', 'e78' ),
    		'set_featured_image'       => esc_html__( 'Set featured image', 'e78' ),
    		'remove_featured_image'    => esc_html__( 'Remove featured image', 'e78' ),
    		'use_featured_image'       => esc_html__( 'Use as featured image', 'e78' ),
    		'menu_name'                => esc_html__( 'Case Studies', 'e78' ),
    		'filter_items_list'        => esc_html__( 'Filter case studies list', 'e78' ),
    		'filter_by_date'           => esc_html__( '', 'e78' ),
    		'items_list_navigation'    => esc_html__( 'Case Studies list navigation', 'e78' ),
    		'items_list'               => esc_html__( 'Case Studies list', 'e78' ),
    		'item_published'           => esc_html__( 'Case Study published.', 'e78' ),
    		'item_published_privately' => esc_html__( 'Case Study published privately.', 'e78' ),
    		'item_reverted_to_draft'   => esc_html__( 'Case Study reverted to draft.', 'e78' ),
    		'item_scheduled'           => esc_html__( 'Case Study scheduled.', 'e78' ),
    		'item_updated'             => esc_html__( 'Case Study updated.', 'e78' ),
    		'text_domain'              => esc_html__( 'e78', 'e78' ),
    	];
    	$args = [
    		'label'               => esc_html__( 'Case Studies', 'e78' ),
    		'labels'              => $labels,
    		'description'         => '',
    		'public'              => true,
    		'hierarchical'        => true,
    		'exclude_from_search' => false,
    		'publicly_queryable'  => true,
    		'show_ui'             => false,
    		'show_in_nav_menus'   => true,
    		'show_in_admin_bar'   => true,
    		'show_in_rest'        => true,
    		'query_var'           => true,
    		'can_export'          => true,
    		'delete_with_user'    => true,
    		'has_archive'         => true,
    		'rest_base'           => '',
    		'show_in_menu'        => true,
    		'menu_position'       => 5,
    		'menu_icon'           => 'dashicons-clipboard',
    		'capability_type'     => 'post',
    		'supports'            => ['title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'],
    		'taxonomies'          => [],
    		'rewrite'             => [
    			'slug'       => 'case-studies',
    			'with_front' => false,
    		],
    	];
    
    	register_post_type( 'case_study', $args );
    }
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.