Currently I am trying to add a page as a child in my custom post section. The parent pages in my custom posts works correctly, I’ve set a template file for them as singe-custom_post_name.php. All good. Now I have added support to create child pages, I am able to create those pages in my custom post type section but when I navigate to the url a template couldn’t be found.
What are the possible problems or solutions to this kind of problem? As far I don’t understand where this problem is coming from but I guess there should be something to do with he slug?
domain.com/%custom_post_title%/ works
domain.com/%custom_post_title%/%child_title%/ template not found..
Any feedback is welcome, hope we get this issue solved, thanks!
1 Answer
It turns out the WordPress permalink structure works perfectly well for custom types, e.g. example.com/recipes/lunch/sandwich/. This works exactly as expected if you set ‘hierarchical’ => true.
What I was originally trying to do was unnecessarily difficult to execute, and requires properly setting up a custom permalink structure to avoid 404 errors. I advise you stick with the standard WordPress hierarchical permalink functionality.