Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
80 views
in Technique[技术] by (71.8m points)

CPT Archive In Wordpress Menu

I'm trying to add the actual Archive in my Wordpress menu, (without needing to do a custom link to it, as I am now to... https://domain-name.com/services/).

I'd like my client to be able to select the services archive from the options on the left in the menu area.

I don't want to list out the various services within this archive (see functions php below) hence me keeping the;

'show_in_nav_menus' => false;

What I instead want to be selectable in the menu section is the actual archive, in this case 'services' as per the page slug.

I expected to see this in the menu area under categories, but it's not there?

     function custom_services_post_type()
{
    $args = array(
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'exclude_from_search' => true,
        'show_in_nav_menus' => false,
        'has_archive' => true,
        'hierarchical' => true,
        'labels' => array(
            'name' => 'Our Services',
            'singular_name' => 'Service',
            'add_new' => __('Add A Service'),
            'add_new_item' => __('New Service'),
            'edit_item' => __('Edit The Service'),
            'new_item' => __('New Service'),
            'all_items' => __('All Services'),
            'view_items' => __('View Services'),
            'menu_name' => 'Services'
        ),
        'supports' => array(
            'title',
            'custom-fields',
            'post-formats'
        ),
        'description' => 'Biddenden Chiropractic services',
        'menu_icon' => 'dashicons-list-view',
    );
    register_post_type('services', $args);
}
add_action('init', 'custom_services_post_type');
question from:https://stackoverflow.com/questions/65921894/cpt-archive-in-wordpress-menu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...