我在使用MySQL 5.7.9和PHP 7的W2012服务器上使用WordPress 4.7。 我有一个子主题,在我的孩子主题中,我创建了一个自定义的帖子类型,其代码如下。 在WP设置中,永久链接结构设置为" post name"。 固定链接适用于页面和帖子,但我的自定义帖子类型有奇怪的行为。
我创建了一个带有slug' accueil-parcours-107'的自定义帖子类型。在父自定义帖子类型下使用slug' place-01'。
当我输入https://responsive.knowledgeplaces.com/accueil-parcours-107/时 我被重定向到https://responsive.knowledgeplaces.com/places/place-01/accueil-parcours-107/
我想得到404错误,我该怎么做?
以下是自定义帖子类型的代码:
register_post_type( 'kpcms_place',
array(
'labels' => array(
'name' => __( 'Knowledge Places Pages', 'KPCMS' ),
'singular_name' => __( 'Knowledge Place Page', 'KPCMS' ),
'add_new_item' => __( 'Add a Knowledge Place Page', 'KPCMS' ),
'edit_item' => __( 'Edit Knowledge Place Page', 'KPCMS' ),
'new_item' => __( 'New Knowledge Place Page', 'KPCMS' ),
'view_item' => __( 'View Knowledge Place Page', 'KPCMS' ),
'search_items' => __( 'Search Knowledge Places Pages', 'KPCMS' ),
'not_found' => __( 'No Knowledge Places Pages found', 'KPCMS' ),
'not_found_in_trash' => __( 'No Knowledge Places Pages found in Trash', 'KPCMS' ),
'parent_item_column' => __( 'Parent Knowledge Place Page:', 'KPCMS' ),
'all_items' => __( 'All Knowledge Places Pages', 'KPCMS' ),
'insert_into_item' => __( 'Insert into Knowledge Place Page', 'KPCMS' ),
'uploaded_to_this_item' => __( 'Uploaded to this Knowledge Place Page', 'KPCMS' ),
'menu_name' => __( 'Knowledge Places' )
),
'query_var' => true,
'public' => true,
'hierarchical' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'menu_icon' => 'dashicons-location',
'rewrite' => array(
'slug' => 'places'
),
'taxonomies' => array(
'category',
'post_tag'
),
'capabilities' => array(
'edit_post' => 'edit_kpcms_place',
'read_post' => 'read_kpcms_place',
'delete_post' => 'delete_kpcms_place',
'edit_posts' => 'edit_kpcms_places',
'edit_others_posts' => 'edit_others_kpcms_places',
'publish_posts' => 'publish_kpcms_places',
'read_private_posts' => 'read_private_kpcms_places',
'create_posts' => 'edit_kpcms_places'
),
'supports' => array(
'title',
'editor',
'author',
'comments',
'revisions',
'page-attributes'
),
)
);