2
votes

I've searched extensively on this issue and have found others with similar problems, but no solutions that work in my case.

The situation is this:
* I have created a custom post type with the slug 'events'.
* I have created a page with the slug 'events'.
* I have added child pages to the events page (first-level children)
* I have added child pages to those child pages (second-level children)
* The permalink structure is set to /%category%/%postname%/
* I am not using any plugins or custom code to handle custom post types.
* When I navigate to /events/, the page loads fine using the pages.php template.
* When I navigate to /events/first-level-child/ I get a 404.
* When I navigate to /events/first-level-child/second-level-child/ the page loads fine using the page.php template.
* When I navigate to /events/category-name/ the page loads fine using the archive.php template.

The problem is the 404 I get when trying to view a first-level child page of the page with the same slug as that of a custom post type.

It is not an option for me to rename either of the slugs so that they're different. I need to find a way to get both child pages and categories to work as expected for the Events page. I cannot create custom redirects in the .htaccess file for the child pages as the client must be able to create them themselves.

Is there some way to modify the rewrite rules generated by WordPress to achieve my goal? Or is there maybe a plugin that I could utilize that would help? I'm guessing that WordPress expects the second uri segment to be a category name. Is there a way to have it look for pages with that name if no category is found?

1

1 Answers

0
votes

Looks like the solution here is to define a custom taxonomy for the custom post type with a slug different than the slug for the post type itself.

In this case the slug for the post type is 'events' and the slug for the taxonomy is 'events/category'. Doing this allows the child pages to display as well as the categories for the post.