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 am trying to add action hook in functions.php only if the page is home.php but the following does not work

if ( is_page_template("home.php") ) {

// do stuff


To make sure that file being used is home.php I do this

global $template; echo $template; 
share|improve this question

1 Answer 1

up vote 7 down vote accepted

Use is_home instead, as is_page_template will not work for home.php as its technically not a page template in the traditional sense.

add_action('template_redirect', 'are_we_home_yet', 10);
function are_we_home_yet(){
        if ( is_home() ) {
        //your logic here


add_action('template_redirect', 'are_we_home_yet', 10);
function are_we_home_yet(){
        global $template;
        $template_file = basename((__FILE__).$template);
        if ( is_home() && $template_file = 'home.php' ) {
        //do your logic here

The revised answer is actually what you really need, it will check if you are on the home page, in addition to getting the template file being included and check to see if that file is in fact your home.php file and if so, you can go about your logic...

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.