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.
Related Posts:
- Can I make WordPress use a custom template for a child page
- How do I find out which (page) template file my custom child post is looking for?
- WordPress custom post type and page
- What are the differences between custom post type and custom page templates?
- How To Limit Hierarchical Pages Depth (For Custom Post Types) To Children Only
- Automatically create child pages when saving a (parent) page
- Loading custom page template via plugin
- Ordering Posts List By Taxonomy Terms?
- WordPress keeps fetching the archive page instead of the template page
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- How to add custom template in plugin?
- How to quickly switch custom post type singular template?
- How to use a dedicated template for the Custom Post Type from a plugin?
- How to sort list of custom posts to get view like a tree of posts under categories and their children’s categories?
- Display posts of custom type in hierarchical order
- WordPress custom post type Single.php?
- Custom Post Types, Page Templates and Pagination. Why do I get a 404 Error?
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Query in a Hierarchical Custom Post Type for Children vs Siblings
- Detect if 1st, 2nd or 3rd level custom page?
- Create second custom 404 page for selected post type
- Custom post type routing with hierarchy
- is_page_template not working as expected
- Custom post type hierarchical permalinks not behaving as expected for parent/child pages
- Hyphens instead of Underscores in Post-type Archive Template Filenames when Post-type handle contains underscore
- Share parent path between Custom Post Types and Pages?
- Page as a child of a Custom Post Type
- Create Template for Custom Post Type same like for Page
- How to load a template without it being assigned to a page/post?
- Custom template with CPT doesn’t display on frontend
- Custom rewrite rule for hierarchical custom post type
- Custom Post Type with Templates using Meta Boxes?
- List children on child post
- Posts are duplicating on wp_post_update
- Custom-Posttype & Custom Taxonomy WP_Query
- Page template with different page and post content
- Custom page sidebar using Template dropdown box
- Child post with numeric only slug keeps redirecting to parent
- Next and Previous Posts of Same Parent
- Adding sidebar to template creates horizontal gap the size of the side bar
- How to render a custom post type template with custom fields using shortcode
- Display Child Pages of Custom Post Type Parent Page
- Versioned Custom Post Type (Not the same as revisions)
- Custom post Type, child of a Page?
- What code should I use to display children of a custom post?
- Custom Post Type Template Alternative
- General advice on addressing content-centric pages
- next_/previous_post_link() `in_same_category` appears to fail when true
- Multiple templates for single custom post type
- WordPress Custom Search by post_type
- Pages Become “Archive” Instead of Using Page Template
- Custom post type pages return 404 page?
- Multiple single templates?
- Custom URL redirect in WP
- Include php on a specific page template
- List of child custom post types lists all custom post types
- page template for custom post type
- Page Template Dropdown For Custom Post Types
- Redirect to first child on Custom Post Type (without template)
- How to integrate single and archive templates for custom post type in any WordPress theme
- providing access to post_id or post inside functions.php
- wp_get_canonical_url showing first url of the post for custom page
- Query to get child pages of current page and display it in action hook
- How can I modify a custom post type and custom page template for a child theme if all content seams to be handled by theme’s ‘native’ plugin?
- Mixing Custom Post Types and Page Templates in WordPress 3.7.1
- Custom Post Type Template Insert not working properply
- Loop and add Specific Categories and Products Images
- Custom Post Type page template doesn’t show up
- How can I allow users to edit text that will be displayed on a custom post type archive page?
- Problem with custom loop navigation inside the blog page
- WordPress giving me the index
- Migrate Custom Post Type with Custom Fields data and parent child order
- Can I automatically assign a page template to a custom post type (i.e page-slug.php file)
- Virtual page and loading template
- Custom Post type dont use custom page template (slug is not right)
- How to create additional rendering for custom post types?
- Set a template on a custom post in the plugin
- How can I use a custom template to load custom post type posts based on a post_meta value
- Showing Custom Post Type with his templates on a custom page template
- Question on templates
- Display a list of sub-pages of Custom Post Type Parent Page
- I have a problem with displaying children pages of custom post type
- How can I load Template file from wordpress plugin
- Redirect sub-page URLs to parent without changing URL
- Ordering Posts List By Taxonomy Terms?
- Loading a template for a URL pattern
- Child Theme problems
- Custom Homepage As Single Page or Custom Post Type?
- Templates list in “Page Attributes” metabox is inaccurate
- Custom Post Type & Page Template
- Custom post type child page 404
- Using custom post types within a section of a template
- How do I paginate a custom post type listing on a custom template page?
- Custom Post Type order Title ASC
- get tags from custom post type
- Custom Post Type Template Based on Page Slug?
- Page templates for custom post types
- using a template for more then 1 page
- I want to show a list of posts under specified categories
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs