This issue seems to be quite common, but the solutions that worked for others haven't worked for me.
I'm using the CPT UI plugin and have created a CPT called 'courses' with the following settings:
register_post_type('courses', array( 'label' => 'Courses', 'description' => '', 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'hierarchical' => true, 'rewrite' => array('slug' => 'courses', 'with_front' => true), 'query_var' => true, 'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'), 'labels' => array ( 'name' => 'Courses', 'singular_name' => 'Course', 'menu_name' => 'Courses', 'add_new' => 'Add Course', 'add_new_item' => 'Add New Course', 'edit' => 'Edit', 'edit_item' => 'Edit Course', 'new_item' => 'New Course', 'view' => 'View Course', 'view_item' => 'View Course', 'search_items' => 'Search Courses', 'not_found' => 'No Courses Found', 'not_found_in_trash' => 'No Courses Found in Trash', 'parent' => 'Parent Course', ) I then created a page called 'courses' and a specialized page template called 'page-courses.php' and a template called 'single-courses.php' for any posts within the courses custom post type. Up to now everything worked correctly.
Next, I created a new page with the slug of 'questions-checkout' and 'courses' as it's parent. It is this page that gives a 404.
I've tried the following to get it working:
- In admin: settings > permalinks and resaved added
flush_rewrite_rules();to functions.php and refreshed the 'questions-checkout' page - Installed 'rewrite rules' plugin and flushed the rewrite rules
- Created a new custom post type using CPT UI.
Using one or more of the above 3 fixes does indeed fix the 404 on 'questions-checkout'. However, I then get a 404 on posts within the courses page e.g. /courses/post-title.
No matter how hard I try, it's one or the other that works - I can't get both courses posts and child pages to be 404-free.
Strictly speaking, I know that pages should not have the same name as a custom post type, so I suspect this is the cause of the 404. My next approach was to delete the 'courses' page, and its child 'questions-checkout'. Then I changed 'page-courses.php' to 'archive-courses.php' and set 'has_archive' to 'true'.
So as it stands, I have a working archive pages and singular pages for my 'courses' custom post type. But how can I now add a page called 'questions-checkout' with the URL /courses/questions-checkout ?
I'm using WordPress 3.9.1 multisite.