I’ve placed the following code in my functions.php file
if(!is_home()){ echo "Not Home";}
if(is_home()){ echo "Home";}
However, no matter what page I’m on, I get “Not Home”, And I’m real sure I’m on the home page, but still get “Not Home”. What am I missing?
If you just place it in
functions.php
, not in a function infunctions.php
, it will be called too early. WordPress includesfunctions.php
before it parses the URL and determines whether you are actually on the homepage or not.Since WordPress 3.1 there is an extra warning (only visibile if you enable
WP_DEBUG
) if you call these too early, to prevent these confusing situations.