The parse_query()
method of the WP_Query
class sets the variables on which the conditional tags are based.
The parse_query
hook are executed before returning from parse_query()
method, variables are already set (eg. is_home
, used by is_front_page()
) and is_front_page()
will work, but function that changes the current state can be hooked to parse_query
(it's still parse_query()
method, which sets variables like is_home
).
Hooks pre_get_posts
is executed directly after parse_query
, that is why it is for me the first safe hook to use conditional tags.
Conditional Tags in Codex
You can only use conditional query tags after the posts_selection
action hook in WordPress (the wp
action hook is the first one through which you can use these conditionals). For themes, this means the conditional tag will never work properly if you are using it in the body of functions.php
, i.e. outside of a function.
However: if you have a reference to the query object (for example, from within the parse_query
or pre_get_posts
hooks), you can use the WP_Query conditional methods (eg: $query->is_search()
)