I run this code in


as well in


<?php echo is_page_template( 'front-page.php' ) ? "yes" : "no" ?>

and get both times "no" printed

i tried as well

<?php echo get_page_template() ?>

returning nothing.

I as well tried

  <?php echo get_category_template() ?>

What I want to know, is in which main template file I am. E.g.

I want to call from header.php

<?php if ( currFilename(__FILE__) != "front-page" ) : ?>
    <div>Fancy slogan</div>
<?php endif; ?>

which obviously does not work this way.


1 Answer 1


Have you tried is_front_page()? It should do what you're looking to do.

Unless you've set up front-page.php with the Page Template commented header syntax that identifies the file is a Page Template, I don't think you can use the is_page_template() or get_page_template() functions.

As for the category page, if you are loading category-foo.php, then aren't you already aware of what category template you are on and therefore do not need a conditional? Maybe I don't understand the context of the second part to the question.

  • 1
    well, you are ONLY aware in the category template. You are not aware in the header where you are. And if I understand correctly, there is, sadly, no way to set a variable in category-foo.php that can be read in the header in plain php.
    – Toskan
    May 21, 2015 at 18:53
  • Ah, I get it now. I think what you want then is is_category. May 21, 2015 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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