I have created a hierarchical custom post type in wordpress called “films.” It is hierarchical so it can have children elements.
When a “film” is clicked, wordpress automatically uses the template called ‘single-films.php’. That is great, but I wish to use a different template when one of the film’s children pages is clicked. For instance, a child of a film might be “press.” When that film’s press link is clicked, I want it to use a different template than single-films.php.
I was hoping there is some way I can use a template like single-children-films.php. Any ideas how I can change a hierarchical custom post type’s children template?
If, from within
single-films.php
you filter based on the parent post you should have little issue with this. For example:If you need to know how deep the page is, that’s a different matter, but that’s also doable (unfortunately it means you need to query the database though).