Finding out which Wordpress template is used for a page from admin page Finding out which Wordpress template is used for a page from admin page wordpress wordpress

Finding out which Wordpress template is used for a page from admin page


If your specific problem is with the home page, you could use a combination of get_page_template() and comparing the edited page's ID with get_option('page_on_front') (see WordPress option reference). There's also an option, show_on_front, which indicates whether the front page shows posts or a static page.

Maybe this helps? I don't know if there are other edge cases where a different template will be used...


Use get_page_template():

<?php echo realpath(get_page_template()); ?> 

It outputs something like /foo/bar/baz/wp-content/themes/your-theme/{page-template}.php

You can choose not to use realpath() and just get the template name.


The only solution I found is this:

global $template;echo basename($template); // front-page.php

I know it's ugly, but I just couldn't find a way to not use this global variable.