WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't see any way of testing which template file is being loaded, if the template file is not a page template. Otherwise I would use is_page_template().

For instance, I am using a home.php template file to pull in the content from multiple pages(don't ask), how would I check that home.php is the template file being used when viewing the sites root url?

share|improve this question
up vote 2 down vote accepted

Just type in some text like "Debug" into the non-Php area of home.php (the part not surrouded by ) and see if it appears. If so, you know that home.php is being used.

share|improve this answer

I do not think this is common practice or that WP tracks such either. Conditional Tags are very flexible and usually sufficient to build conditional logic.

If you really need this I'd look into __FILE__ constant and debug_backtrace().

share|improve this answer

We can see the template file name in body tag by doing a view page source like page-templatesfront-page-php in WordPress twenty twelve theme. If we need to check in code, then get page template slug.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.