Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

3 Answers

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
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.