Take the tour ×  So I've the following code in order to search
for templates inside a custom theme I'm working on:  <?php
$my_theme = wp_get_theme(); get_template_part( 'masthead',
$my_theme->Template); ?>  Basically what it does, is that it
does a search for a file called "masthead-themename.php". If
that file does not exists, then it looks for a file called
"masthead.php". This works as expected.  However, I would to
have something that searches for the file inside of a folder
called "templates" as a first option and if not, then search for
the template name in the theme's root folder.  I tried this
<?php $my_theme = wp_get_theme(); get_template_part(
'templates/masthead',  $my_theme->Template); ?>  But this only
works if the file exists in the template's folder. If the file
exists in the root's theme folder, it does not recognize it.
Any ideas?   share|improve this question add comment  1 Answer
I assume you have a file in templates/masterhead-
templatename.php, and it works, it is ok.  Correct me if I