如何在WordPress中阻止自定义帖子类型列表页面?

问题描述 投票:0回答:2

我正在WordPress网站上工作,并且自定义帖子类型功能存在问题。我创建了一个名为“ cust_team”的帖子类型,并且永久链接设置为帖子名称:

职位名称:http://example.com/mytheme/sample-post/

现在,当我查看“ http://example.com/mytheme/cust_team”页面时,它向我显示了所有“ cust_team”帖子的列表。但是,当我查看http://example.com/mytheme/post或页面时,它会重定向到404页面。我只想阻止自定义帖子类型列表页面,因为它在SEO中创建了重复的内容问题。

这里是我的注册员类型数组::

$cpt_args['cust_team'] = array(
    'labels' => array(
        'name'              => esc_html__('Team Member','mytheme'),
        'singular_name'     => esc_html__('Team Member','mytheme'),
        'add_new'           => esc_html__('Add Team Member','mytheme'),
        'add_new_item'      => esc_html__('Add Team Member','mytheme'),
        'edit_item'         => esc_html__('Edit Team Member','mytheme'),
        'new_item'          => esc_html__('New Team Member','mytheme'),
        'all_items'       => esc_html__( 'All Team Members','mytheme'),
        'not_found'         => esc_html__('No Team Member found','mytheme'),
        'not_found_in_trash'    => esc_html__('No Team Member found in Trash','mytheme'),
        'menu_name'                 => esc_html__('Team Members','mytheme'),
    ),
    'description'       => 'Manage Team Content.',
    'public'                => true,
    'publicly_queryable' => true,
    'show_in_nav_menus'     => true,
    'supports'              => array(
    'title',
    'thumbnail',
    'editor',
    'page-attributes',
    'custom-fields'
    ),
    'show_ui'               => true,
    'show_in_menu'      => true,
    'menu_position'         => 5,
    'has_archive'           => true,
    'menu_icon'             => 'dashicons-admin-post',
    'query_var'             => true,
    'rewrite'               => '',
    'capability_type'   => 'post',
    'map_meta_cap'          => true,
    'rewrite'               => array('slug'  => 'cust_team'),
);

[请告诉我我在做什么错。我想删除自定义帖子类型列表页面,就像默认帖子类型“帖子”和“页面”一样。

wordpress wordpress-theming custom-post-type
2个回答
0
投票

将以下设置为false:

'has_archive' => false

您可以在WordPress documentation中了解有关帖子类型的更多信息>


0
投票

请设置'has_archive' => false'rewrite' => false

© www.soinside.com 2019 - 2024. All rights reserved.