I'm trying to check whether the page.php template is being used or not. I've tried is_page_template( 'page.php' )
but it doesn't work.
I also can't use is_page()
because I only want to do something when page.php
is used, and not when some other custom Page template is used.
Please let me know about this and thanks!
Edit: Should have mentioned earlier that I have a file called common-options.php
which is getting included in almost all the templates (like index.php
, page.php
, single.php
and page_blog.php
), in this file I'm trying to do the check with the following code:
if ( is_page_template( 'page.php' ) ) {
echo "success!";
}
But it's not working when I open a page that is using the "Default Template".
is_page_template
will not work. My recommendation is to find out which template is being use and then track down why. This function will display the current template file on every page to a logged in admin. pastebin.com/wkNv9Eug. Stick this in your functions.php and reload the page. As long as your theme calls wp_head() you should see the template at the top of every page when logged in.the_post
in your template file before callingis_page_template
? (is_page_template( 'page.php'
won't work either way, but this is still an important question in answering your original question)