[wp-hackers] is_front_page() after modifying query_posts

Otto otto at ottodestruct.com
Fri Mar 11 20:22:15 UTC 2011


On Fri, Mar 11, 2011 at 2:08 PM, Jesus Lizama <beautifulcrimes at gmail.com> wrote:
> I will also say yes. is_front_page() should always return true for
> index.php.

No, it shouldn't, for a few reasons.

First, in WP, *all* pages are really "index.php". So I assume you
meant for the root page. http://example.com/ for example.

Secondly, all the is_whatever() functions are based around the current
main query. is_archive() will return true on any archive page.
is_category() returns true on any category archive page. is_page(),
is_single(), etc., all of them are based on the current query.

Now, is_front_page() is also based on the current query, as well as
the front page setting on the Settings page. If you change the query
to something else, then you're not on the front page anymore.

If you want to base something on the current state of the URL, then
you should examine the actual URL instead. The is_* functions are
evaluating the state of the main page query, and they should all do
that consistently.

-Otto


More information about the wp-hackers mailing list