[wp-hackers] Re: odd posts query on 404
Ryan Boren
ryan at boren.nu
Thu Jan 17 22:41:38 GMT 2008
On Jan 17, 2008 2:21 PM, Casey Bisson <casey.bisson at gmail.com> wrote:
> So here's my question:
> Do we actually want to execute that query for every 404 under normal
> circumstances? If not, is this (or something like this) the stupidest
> solution?
>
> wp-includes/classes.php:WP->query_posts()
>
> function query_posts() {
> global $wp_the_query;
> $this->build_query_string();
>
> // return if the request URI is a 404
> if( $this->did_permalink && $this->query_vars['error'] == '404' )
> return;
>
> $wp_the_query->query($this->query_vars);
> }
>
> The above works, but there's probably a better way to write it.
wp-includes/canonical.php and some 404 templates expect that
WP_Query::parse_request() has run. I think calling that on its own
without calling the DB parts of WP_Query would work.
Ryan
More information about the wp-hackers
mailing list