If you just place it in functions.php
, not in a function in functions.php
, it will be called too early. WordPress includes functions.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.