CPT don't appear on menu creation options

Support MB Custom Post Type CPT don't appear on menu creation optionsResolved

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #33773
    MigeckoMigecko
    Participant

    Why a CPT and a custom taxonomy created with Metabox Builder don't appear in: Appearance -> Menu -> Add menu item?

    #33786
    Long NguyenLong Nguyen
    Moderator

    Hi Migecko,

    When creating the CPT or custom taxonomy, please enable the option "Show in nav menus" in the "Advanced" tab to make it available for selection in the menu. Screenshot https://monosnap.com/file/WQTxfzixLuPOIUVfXnf0sIufP6gSbg

    If it does not work, you can try to re-save permalink settings (Post name) to flush the cache and re-check the menu item.

    #33793
    MigeckoMigecko
    Participant

    Hi, Long Nguyen!

    Thanks. I've tried re-check "show in nav menus" and re-save permalinks, but it stills no available for selection in menus.

    I don't understand it, because if I create a new CPT or taxonomy, appears correctly in menu selection.

    #33810
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Can you please share the code that creates the CPT on your site? It is possible that there is an issue with the CPT slug or another setting.

    #33817
    MigeckoMigecko
    Participant

    Here you are (from Button "get php code" of the builder):

    This is a CPT:

    <?php
    add_action( 'init', 'your_prefix_register_post_type' );
    function your_prefix_register_post_type() {
        $labels = [
            'name'                     => esc_html__( 'Deportes', 'your-textdomain' ),
            'singular_name'            => esc_html__( 'Deportes', 'your-textdomain' ),
            'add_new'                  => esc_html__( 'Añadir nueva', 'your-textdomain' ),
            'add_new_item'             => esc_html__( 'Nueva noticia', 'your-textdomain' ),
            'edit_item'                => esc_html__( 'Editar noticia', 'your-textdomain' ),
            'new_item'                 => esc_html__( 'Nueva noticia', 'your-textdomain' ),
            'view_item'                => esc_html__( 'Ver noticia', 'your-textdomain' ),
            'view_items'               => esc_html__( 'View Deportes', 'your-textdomain' ),
            'search_items'             => esc_html__( 'Search Deportes', 'your-textdomain' ),
            'not_found'                => esc_html__( 'No deportes found', 'your-textdomain' ),
            'not_found_in_trash'       => esc_html__( 'No deportes found in Trash', 'your-textdomain' ),
            'parent_item_colon'        => esc_html__( 'Parent Deportes:', 'your-textdomain' ),
            'all_items'                => esc_html__( 'Noticias', 'your-textdomain' ),
            'archives'                 => esc_html__( 'Deportes Archives', 'your-textdomain' ),
            'attributes'               => esc_html__( 'Deportes Attributes', 'your-textdomain' ),
            'insert_into_item'         => esc_html__( 'Insert into deportes', 'your-textdomain' ),
            'uploaded_to_this_item'    => esc_html__( 'Uploaded to this deportes', 'your-textdomain' ),
            'featured_image'           => esc_html__( 'Featured image', 'your-textdomain' ),
            'set_featured_image'       => esc_html__( 'Imagen destacada', 'your-textdomain' ),
            'remove_featured_image'    => esc_html__( 'Borrar imagen destacada', 'your-textdomain' ),
            'use_featured_image'       => esc_html__( 'Usar como imagen destacada', 'your-textdomain' ),
            'menu_name'                => esc_html__( 'Deportes', 'your-textdomain' ),
            'filter_items_list'        => esc_html__( 'Filter deportes list', 'your-textdomain' ),
            'filter_by_date'           => esc_html__( '', 'your-textdomain' ),
            'items_list_navigation'    => esc_html__( 'Deportes list navigation', 'your-textdomain' ),
            'items_list'               => esc_html__( 'Deportes list', 'your-textdomain' ),
            'item_published'           => esc_html__( 'Deportes published', 'your-textdomain' ),
            'item_published_privately' => esc_html__( 'Deportes published privately', 'your-textdomain' ),
            'item_reverted_to_draft'   => esc_html__( 'Deportes reverted to draft', 'your-textdomain' ),
            'item_scheduled'           => esc_html__( 'Deportes scheduled', 'your-textdomain' ),
            'item_updated'             => esc_html__( 'Deportes updated', 'your-textdomain' ),
        ];
        $args = [
            'label'               => esc_html__( 'Deportes', 'your-textdomain' ),
            'labels'              => $labels,
            'description'         => '',
            'public'              => true,
            'hierarchical'        => false,
            'exclude_from_search' => false,
            'publicly_queryable'  => true,
            'show_ui'             => true,
            'show_in_nav_menus'   => true,
            'show_in_admin_bar'   => true,
            'show_in_rest'        => false,
            'query_var'           => true,
            'can_export'          => true,
            'delete_with_user'    => false,
            'has_archive'         => true,
            'rest_base'           => '',
            'show_in_menu'        => true,
            'menu_position'       => 5,
            'menu_icon'           => 'dashicons-admin-site',
            'capability_type'     => 'post',
            'supports'            => ['title', 'editor', 'thumbnail', 'author'],
            'taxonomies'          => ['c-deportes', 'e-deportes'],
            'rewrite'             => [
                'with_front' => false,
            ],
        ];
    
    register_post_type( 'deportes', $args );
    }

    This is a taxonomy for the previous CPT:

    <?php
    add_action( 'init', 'your_prefix_register_taxonomy' );
    function your_prefix_register_taxonomy() {
        $labels = [
            'name'                       => esc_html__( 'Categorías', 'your-textdomain' ),
            'singular_name'              => esc_html__( 'Categoría', 'your-textdomain' ),
            'menu_name'                  => esc_html__( 'Categorías', 'your-textdomain' ),
            'search_items'               => esc_html__( 'Search Categorías', 'your-textdomain' ),
            'popular_items'              => esc_html__( 'Popular Categorías', 'your-textdomain' ),
            'all_items'                  => esc_html__( 'All Categorías', 'your-textdomain' ),
            'parent_item'                => esc_html__( 'Parent Categoría', 'your-textdomain' ),
            'parent_item_colon'          => esc_html__( 'Parent Categoría', 'your-textdomain' ),
            'edit_item'                  => esc_html__( 'Editar categoría', 'your-textdomain' ),
            'view_item'                  => esc_html__( 'Ver categoría', 'your-textdomain' ),
            'update_item'                => esc_html__( 'Actualizar categoría', 'your-textdomain' ),
            'add_new_item'               => esc_html__( 'Añadir nueva categoría', 'your-textdomain' ),
            'new_item_name'              => esc_html__( 'New categoría name', 'your-textdomain' ),
            'separate_items_with_commas' => esc_html__( 'Separate categorías with commas', 'your-textdomain' ),
            'add_or_remove_items'        => esc_html__( 'Add or remove categorías', 'your-textdomain' ),
            'choose_from_most_used'      => esc_html__( 'Choose most used categorías', 'your-textdomain' ),
            'not_found'                  => esc_html__( 'No categorías found', 'your-textdomain' ),
            'no_terms'                   => esc_html__( 'No Categorías', 'your-textdomain' ),
            'filter_by_item'             => esc_html__( 'Filter by categoría', 'your-textdomain' ),
            'items_list_navigation'      => esc_html__( 'Categorías list pagination', 'your-textdomain' ),
            'items_list'                 => esc_html__( 'Categorías list', 'your-textdomain' ),
            'most_used'                  => esc_html__( 'Most Used', 'your-textdomain' ),
            'back_to_items'              => esc_html__( 'Back to categorías', 'your-textdomain' ),
        ];
        $args = [
            'label'              => esc_html__( 'Categorías', 'your-textdomain' ),
            'labels'             => $labels,
            'description'        => '',
            'public'             => true,
            'publicly_queryable' => true,
            'hierarchical'       => true,
            'show_ui'            => true,
            'show_in_menu'       => true,
            'show_in_nav_menus'  => true,
            'show_in_rest'       => true,
            'show_tagcloud'      => true,
            'show_in_quick_edit' => true,
            'show_admin_column'  => false,
            'query_var'          => true,
            'sort'               => false,
            'meta_box_cb'        => 'post_tags_meta_box',
            'rest_base'          => '',
            'rewrite'            => [
                'with_front'   => false,
                'hierarchical' => false,
            ],
        ];
        register_taxonomy( 'c-deportes', ['deportes'], $args );
    }

    Thanks!

    #33838
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I do not see any issue on my site, the CPT is available on the list menu items as well, screenshot https://monosnap.com/file/XZyAVOEYDXSDxTG5vkRGun4YhaBIc4

    You can try again with a fresh WordPress install to avoid any conflicting issues.

    #33889
    MigeckoMigecko
    Participant

    Another clue for my problem.

    Viewing the page code from the chrome code inspector, the CPT and its categories are in the accordion code, but hidden by CSS:

    .hidden, .js .closed .inside, .js .hide-if-js, .js .wp-core-ui .hide-if-js, .js.wp-core-ui .hide-if-js, .no-js .hide-if-no-js, .no-js .wp-core-ui .hide-if-no-js, .no-js.wp-core-ui .hide-if-no-js {
    display: none;
    }

    #33892
    MigeckoMigecko
    Participant

    OMG... these fields are disabled in the screen options (at the top).

    It works now, sorry for the inconvenience.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.