issue with hierarchical custom post type
-
down vote
favorite
I use WordPress 4.7 hosted on a W2012 server with MySQL 5.7.9 and PHP 7. I have a child theme, and in my child theme, I have created a custom post type with the code below. In WP settings, permalinks structure are set to “post name”. Permalinks work fine for pages and posts, but I have strange behaviors with my custom post type.I have created a custom post type with slug ‘accueil-parcours-107’ under parent custom post type with slug ‘place-01’.
When I enter https://responsive.knowledgeplaces.com/accueil-parcours-107/ I am redirected to https://responsive.knowledgeplaces.com/places/place-01/accueil-parcours-107/
I would like to get a 404 error, how can I do this?
Here is the code for custom post type:
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' ), )
- The topic ‘issue with hierarchical custom post type’ is closed to new replies.