[wp-trac] [WordPress Trac] #22299: posts_per_page value in $wp_query does not work in index.php

WordPress Trac noreply at wordpress.org
Sun Oct 28 01:19:05 UTC 2012


#22299: posts_per_page value in $wp_query does not work in index.php
-----------------------------+--------------------------
 Reporter:  alexvorn2        |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  General
  Version:                   |   Severity:  normal
 Keywords:                   |
-----------------------------+--------------------------
 For example we have only 2 posts.
 Using this code to display only one post (title) per page:

 {{{
 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
 $args = array(
         'posts_per_page' => 1,
         'paged' => $paged
 );
 // The Query
 $the_query = new WP_Query( $args );

 // The Loop
 while ( $the_query->have_posts() ) : $the_query->the_post();
         echo '<li>';
         the_title();
         echo '</li>';
 endwhile;

 // Reset Post Data
 wp_reset_postdata();
 }}}

 I inserted this in index.php

 Going to page/2 will show an error instead of the page 2 (with one post
 title) of the actual query. I suspect that this is a bug or I missed
 something?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22299>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list