Finding wordpress file in theme editor using the theme name

In the wordpress admin dashboard, on the pages tab, when you edit the page, there's a section called "Page Attributes". One of the options is "Templates", which opens a drop-down list of templates available.

Is it actually possible to find which template name corresponds to which file in the theme editor without looking through every single file in the theme editor?

Solutions

I'm not entirely certain I understand what you mean but whenever a Page Template is set WordPress also sets postmeta with a specific key and value. The key is called _wp_page_template and the value holds the template location relative to the theme. So you could do this:

$pages_with_templates = new WP_Query( array(
    'post_type'         => 'page',
    'posts_per_page'    => 20,
    'meta_key'          => '_wp_page_template',
) );

This will return a list of pages that have templates, you could narrow it down even more by supplying a value:

$pages_with_this_template = new WP_Query( array(
    'post_type'         => 'page',
    'posts_per_page'    => 20,
    'meta_key'          => '_wp_page_template',
    'meta_value'        => 'template-fullwidth.php',
) );

Now, when I said relative to the theme I mean that if you are using a sub-directory such as:
theme-name/page-templates/template-fullwidth.php the postmeta value will hold:
pages-templates/template-fullwidth.php.

There's also a conditional to test if the current page is using a specific template:

if( is_page_template( 'template-fullwidth.php' ) ) { ... }

Finally, if you're using the body_class() function - WordPress will assign a specific class based on the template to the body tag which you could target if you feel so inclined.

Tags: Themes

Similar questions

SSL finding a file that is not there
I'm working on a wordpress site, and trying to get the ssl lock to show up. But the issue comes with a file that I just cannot find. It doesn't exist and I'm not sure where it is being referenced. error for file that does not exist Is there a way to block this file from being referenced at all? Thanks in advance!
Php script not finding include file
I am running a php command (edited) from the command line that runs a php file on the web server. In that file I need to include a file that is one level up from its location. I have tried and every other suggestion I could find here for the last two days. I keep getting the same error in the CLI: As with all thing computing, I have a sneaking susp...
Finding the index page using the admin panel of wordpress
I am helping out a non profit and they wanted some help in modifying the home page of their site .I looked around the admin area but I couldnt not find the index page anywhere so that I could make the changes. Where should I be looking and if I cant find it from the admin page ,what other ways can I go about finding it.
Finding WordPress sites using my plugins
I've now developed two WordPress plugins and would like to see some sites that use it. I'm looking for a way to find sites that use a WordPress plugin I built. However, the official guidelines, don't allow me to log the hostnames of blogs that install my plugin, for example. Point 7: No "phoning home" without user's informed consent. So, are there ...
Issue with finding first image source in Wordpress post (using regex and PHP)
I am having issues with this regex, which is finding the source of each image in a Wordpress post. At the moment, for example, the first image source outputs as https://www.telecomsworldplc.co.uk/h and not https://www.telecomsworldplc.co.uk/advice/wp-content/uploads/2013/10/globalBusiness.jpg... Any ideas why it is doing this? The code is here... T...
Finding a way to edit a site background in css using wordpress
I am making my first steps coding. I made some courses on Internet and now I am building a wordpress theme to continue learning from the practice. I have a child-theme from the twenty sixteen theme. I found that in the customize section in the wordpress admin I can change the background of the site and also something that is the background of that ...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.