[wp-hackers] is_front_page() after modifying query_posts

Otto otto at ottodestruct.com
Fri Mar 11 20:58:41 UTC 2011

On Fri, Mar 11, 2011 at 2:32 PM, Austin Matzko <austin at ilfilosofo.com> wrote:
> But unlike is_archive(), is_category(), etc., is_front_page() has no
> reasonable scoped use within a custom query.  I may, for example, want
> to know whether the current, custom query is for a category or page,
> no matter that overall page's query was, but there would never be a
> situation in which the custom query result for is_front_page() should
> be different from the main query.

I disagree, because that depends on how you change the query. If
you're only altering one query_var, like say posts_per_page, then you
can still be on the front page with an altered query.

But if you only show posts from a category, then you're not on the
front page anymore, you're showing a category archive.

> So I think it would be reasonable for is_front_page() the function to
> be an exception to the general rule, and return the value of the
> $wp_the_query method, because it already is exceptional.

It isn't exceptional though. That's my point. It's just a way of
checking what's in the query. If you want to check if you're on the
root URL or not, then you shouldn't be looking at the query at all,
and you shouldn't be using is_front_page().

Basically, you're trying to redefine what is_front_page() does, in a
manner that is inconsistent with all of the other query check
functions, and I disagree with that. If you want to check the URL,
then write an entirely new function that does that. Don't change the
existing function to be inconsistent and different, because you'll
break expected behaviors.


More information about the wp-hackers mailing list