[wp-hackers] Any way to bypass $wp->query_posts()?

Otto otto at ottodestruct.com
Thu Apr 9 18:37:54 GMT 2009

On Thu, Apr 9, 2009 at 12:44 PM, Dougal Campbell <dougal at gunters.org> wrote:
> Except that the theoretical plugin in question could tell WP what template
> it wants. I think.

True, and I've thought of that. However, one of the things Mike is
complaining about is, for example, the fact that wp_title requires the
query, or bits that the query loads. To which I respond, yes, it does,
because that is what wp_title *does*. It generates a title based on
what page is loading, and in order to do that, it needs to actually,
you know, load the page's information.

My point is that all pages have *something* that comes from the posts
table. There's more to the posts table than just the content of a

> So, bypassing the query completely is problematic. The main question would
> be whether we are making unnecessary posts queries in cases where the posts
> are going to be thrown away.

While it's true that some bits loaded by the query are not going to be
used in all cases, at least some of it is used in every case I can
think of. Honestly, I can't think of any real case where there's no
information needed from the posts table *and* you're also loading the
theme to display something.. Virtually every theme uses bits from the
posts table in the header, or to load a page template, or *something*.

For the very few edge cases where a plugin is returning something
completely outside of WP, detecting your URL and exiting early is the
best way to accomplish that sort of thing. I've seen a few plugins do
that for simple things like returning images or simple text output for
ajax type queries. In those cases, halting execution early doesn't
affect other plugins because you don't want those other plugins to do
anything anyway, since you're outside the normal scope of a WP


More information about the wp-hackers mailing list