I put a if(is_home())
bit in my theme’s functions.php and it doesn’t seem to work. The function containing this bit is called on init so is_home
should work already.
Leave a Reply
You must be logged in to post a comment.
I put a if(is_home())
bit in my theme’s functions.php and it doesn’t seem to work. The function containing this bit is called on init so is_home
should work already.
You must be logged in to post a comment.
is_home()
won’t work untilwp_query
is run. The earliest hook you can use where is_home will work is'parse_query'
, but'template_redirect'
would be better.To follow up on John’s answer:
Add a call to said function on one of the hooks mentioned by John and hakre.
Add, e.g., the following to your functions.php:
EDIT: I misread your question at first — it looks like you’ve got a function encapsulating the code already, it’s just that you’re firing on the wrong hook. Either break that section out into a separate function and have it fire at template_redirect, etc., or change where you’re hooking in the first place.