I have a directory structure in my theme like this:
src/ templates/ pages/ - faqs.php views/ - page.php
In my custom functions I have a hook that tells WordPress to look in the
src/templates/views directory for basic templates like
page.php, etc. This works fine.
What I would like to do is tell WordPress to look in
src/templates/pages for any custom page templates. From what I understand, WordPress scans the theme directory structure for any page templates but it only goes one-level deep.
For example, my
faqs.php file has a template name of FAQs:
<?php /* Template Name: FAQs */ ?>
If I move
faqs.php to the
src directory it appears in the WP Admin as an available option in the Template dropdown. But when I move it back to
src/templates/pages it is no longer registered.
I have looked for a variety of solutions but haven't found exactly what I'm looking for. It seemed like the theme_page_templates hook might be the answer, but I don't want to have to create the names of the template files in the select list, etc. I would prefer to just tell WordPress where to look and then let WP handle the rest from there. Not sure if that is possible though.