[wp-trac] Re: [WordPress Trac] #6484: have_posts does not seem to work outside of the loop

WordPress Trac wp-trac at lists.automattic.com
Tue Apr 1 05:37:27 GMT 2008


#6484: have_posts does not seem to work outside of the loop
---------------------+------------------------------------------------------
 Reporter:  jsherk   |        Owner:  anonymous
     Type:  defect   |       Status:  closed   
 Priority:  normal   |    Milestone:  2.6      
Component:  General  |      Version:  2.5      
 Severity:  normal   |   Resolution:  invalid  
 Keywords:           |  
---------------------+------------------------------------------------------
Changes (by andy):

  * status:  reopened => closed
  * resolution:  => invalid

Comment:

 Not a bug. Inappropriate use of include. WordPress has no facility for
 guessing what should happen when wp_blog_header.php is included by your
 script.

 The problem is the call to wp(), which assumes the REQUEST_URI is a valid
 URL or query. If you var_dump($wp) after wp() you'll see that it found a
 matching pattern but obviously there are no posts found in the "test.php"
 category.

 {{{
   ["query_vars"]=>
   array(1) {
     ["category_name"]=>
     string(9) "test2.php"
   }
   ["query_string"]=>
   &string(23) "category_name=test2.php"
   ["request"]=>
   string(9) "test2.php"
   ["matched_rule"]=>
   string(8) "(.+?)/?$"
   ["matched_query"]=>
   string(23) "category_name=test2.php"
 }}}

 The solution: include wp-config.php and then call wp() with query vars.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6484#comment:7>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list