I have a custom php file that I want to use as a template (i.e. selecting it from the “Template” dropdown in the image below).
Right now, I have to identify which theme I am using and place the template file in the theme folder.
Is there a place in my filesystem where I can place the template file so it can be used by whichever theme I decide to use later?
1 Answer
No, WordPress has no default place in its system where it will look for templates outside the current theme folder.
That said, you can easily build a plugin that inserts a template into the system. You can use the theme_page_templates
to insert a template name in the dropdown list. Then you hook into template_include
and depending on whether get_page_template_slug
return your template’s slug you divert the template to the one in your plugin-directory.