[wp-trac] [WordPress Trac] #25380: Allow posts_per_page option for pre_get_posts action hook on feed

WordPress Trac noreply at wordpress.org
Sun Sep 22 06:05:11 UTC 2013


#25380: Allow posts_per_page option for pre_get_posts action hook on feed
--------------------------+-----------------------------
 Reporter:  wokamoto      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.6.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 This is a patch to fix an issue where posts_per_page option for
 pre_get_posts action hook does not work while is_feed() is true.

 For example, this code can't change the number of posts per page in a
 feed.
 {{{
 <?php
 function my_pre_get_posts_for_feed( $query ) {
   if ( is_admin() || ! $query->is_main_query() )
     return;

   if ( is_feed() ) {
     // Display 50 posts for the feed
     $query->set( 'posts_per_page', 50 );
   }
 }
 add_action( 'pre_get_posts', 'my_pre_get_posts_for_feed', 1 );
 }}}

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


More information about the wp-trac mailing list