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

Jennifer Hodgdon yahgrp at poplarware.com
Mon Apr 6 03:29:46 GMT 2009

You could do something in the init() action of your plugin, where for 
a particular URL, you can do whatever you want and then exit, 
bypassing all the rest of WP's default actions.

You could also use one of the hooks inside query_posts, to override 
parts of the query, such as the where section, the join section, and I 
think even the whole query.


Mike Schinkel wrote:
> I hope what I'm about to ask isn't viewed as heresy, but I've been building a CustomUrls plugin and am finding that AFAICT WordPress always runs a query for posts no matter if its needed or not, i.e. here is $wp->main() : 
> function main($query_args = '') { 
> $this->init(); 
> $this->parse_request($query_args); 
> $this->send_headers(); 
> $this->query_posts(); 
> $this->handle_404(); 
> $this->register_globals(); 
> do_action_ref_array('wp', array(&$this)); 
> } 
> I would like to be able to disable $wp->query_posts() in cases where I want to run a custom query. Is there a way to do this that I'm just not seeing, or if not is there a reason why it wouldn't make sense to allow bypassing or $wp->query_posts() somehow (and $wp->handle_404() too, for that matter)? 

Jennifer Hodgdon * Poplar ProductivityWare
Drupal, WordPress, and custom Web programming

More information about the wp-hackers mailing list