[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 11:57:06 GMT 2008


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

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

Comment:

 Okay, I could very well be inappropriately using the include, BUT there is
 still something weird going on (which may be a completely different issue
 than what I originally posted). I determined that this is somehow related
 to permalinks.

 The following code worked fine in WP2.3 with permalinks set to 'day &
 name', but does NOT work in WP2.5 with permalinks set 'day & name'. It
 does however work fine in WP2.5 if I change permalinks back to 'default'.
 So how does the permalinks setting affect this code working or not
 working?


 {{{
 <?php
 //Displays the title of the 3 most recent posts in the blog
 $posts_per_page = 3;
 require('./wp-blog-header.php');
 if (have_posts()) : while (have_posts()) : the_post();
 the_title();
 ?><br /><?php
 endwhile; else:
 endif;
 ?>
 }}}

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


More information about the wp-trac mailing list