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

Dougal Campbell dougal at gunters.org
Thu Apr 9 17:10:53 GMT 2009


Otto wrote:
> On Wed, Apr 8, 2009 at 7:23 PM, Mike Schinkel
> <mikeschinkel at newclarity.net> wrote:
>   
>> I'm sorry but I can't take "modify .htaccess" as a serious suggestion for a plugin for reasons I spelled out above. Besides, I *do* need most of WordPress for these URLs, just not ALL of it (i.e. not the query.) Why is my saying "I only don't need the query" being interpreted as "I don't need WordPress at all?"
>>     

The main argument against using a plugin that modifies .htaccess is that 
is not always cross-web-server compatible (e.g. when running under IIS). 
There *are* plugins that modify .htaccess, however (cf, wp-super-cache). 
It wouldn't be my first choice, though. I'd prefer to do these sorts of 
things inside the WordPress framework whenever possible. And yes, WP 
Super Cache is a bit of an exception, because the point of it is to 
bypass WordPress and push caching off onto the http server.

> Because, and I think you're not getting this, the query *IS*
> WordPress. Every page on WordPress needs the query. It's a fundamental
> assumption underlying the whole architecture. ALL pages in WordPress
> are generated from stuff in the posts table. Without exception.
>
> If you're not loading anything from the posts table, then why load any
> part of WordPress at all? There's nothing in WordPress that you need
> if you're not loading something from the posts table as well.
>
>   

I'm afraid there is: a links page (cf, themes/default/links.php). Well, 
and the 404 page (but maybe that one isn't really fair to throw in here ;) )

A couple of other non-standard examples I could think of would be: a 
page that listed authors (or even an author profile page), or a 
'lifestream' page that pulled content from other services.

> See, what you're asking makes absolutely no sense to me. If you don't
> want the query, then why load WordPress at all? Why not bypass
> WordPress in such a way that you can load your own page (which is what
> you claim to want to do) and save all the large amount of processing
> required to load WordPress?
>   

I think the ability to bypass making an actual query, while still 
allowing content to be generated within the existing theme system is 
pretty valid. And all it will take is a filter hook and a conditional at 
appropriate places in the code. Just allow a plugin to wipe the query, 
then abort (returning an empty 'posts' array) before actually sending a 
request to the database engine. Easy-peasy, and lets plugins incorporate 
non-WP content without wasting a posts query to the database.

-- 
Dougal Campbell <dougal at gunters.org>
http://dougal.gunters.org/
http://twitter.com/dougal
http://twitual.com/
*Hire me!*


More information about the wp-hackers mailing list