is_home() not working in functions.php
-
Hi,
I’m creating a theme based on twentyten, and I’ve got a function called custom_head in functions.php that I’m using to register and enqueue scripts. I run custom_head by adding it to my init action:
add_action('init', 'custom_head');
In my custom_head function, is_home() does not work. If I use is_home() in my index.php file, I get the correct expected value (true).
I did a little digging and found that all is_home() does is:
global $wp_query; return $wp_query->is_home;
So I did a print_r on the global $wp_query in my custom_head function and found an empty object. Any ideas why this is? Is there a more proper action I should be using to register my scripts where the global $wp_query object would be populated and valid?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘is_home() not working in functions.php’ is closed to new replies.