[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
Sun Mar 30 22:33:26 GMT 2008


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

 Sorry, here is the code from above in a code block:

 Okay, just so I know I'm not crazy, try this piece of code:


 {{{
 <?php
 require('wp-blog-header.php');
 $myid=10; //put a post id here that you know is valid
 $mytest = get_post($myid);
 echo "Known good post id ".$myid." returns: ".$mytest->post_title;
 $mytest = have_posts();
 if ($mytest=="") { $mytest="nothing"; }
 echo " and have_posts() returns: ".$mytest;
 ?>
 }}}

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


More information about the wp-trac mailing list