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

Dougal Campbell dougal at gunters.org
Thu Apr 9 17:44:33 GMT 2009


Otto wrote:
> On Thu, Apr 9, 2009 at 12:10 PM, Dougal Campbell <dougal at gunters.org> wrote:
>   
>> 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 ;) )
>>     
>
> Sorry, but the default/links.php is a Page Template. If you don't load
> the Page from the posts table, then WordPress has no way to know what
> Page Template it has to use for the given Page.
>
> The 404 I give you, but that's cheating. Anyway, until you run the
> query and get no results, you don't know if a 404 page is required.
>   

Yup, I stand corrected. I didn't think that part through far enough.

>> 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.
>>     
>
> I don't, as without the query, you have no way to know what template
> file is actually needed to be loaded in the first place.
>   

Except that the theoretical plugin in question could tell WP what 
template it wants. I think. However, things start to get hairy here, 
don't they? Somebody (you?) mentioned before about not being able to use 
the_title() and various other bits, but I didn't make the connection 
until you mentioned here about needing to query the page info so that we 
know what template to use. And we have to query the db anyways, just to 
know which theme is active.

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. I can't say that I've looked 
closely enough to know whether or not that is true in any common cases.

-- 
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