#25380 closed defect (bug) (fixed)
Allow posts_per_page option for pre_get_posts action hook on feed
Reported by: | wokamoto | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.6.1 |
Component: | Query | Keywords: | has-patch needs-unit-tests |
Focuses: | Cc: |
Description
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 );
Attachments (3)
Change History (9)
#3
@
11 years ago
- Keywords needs-unit-tests added
- Milestone changed from Awaiting Review to 3.9
I am going to write a few tests for this.
#4
@
11 years ago
- Owner set to wonderboymusic
- Resolution set to fixed
- Status changed from new to closed
In 27455:
This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.
11 years ago
Note: See
TracTickets for help on using
tickets.
Thanks for this, wokamoto. This sounds familiar — there may be a similar bug report I couldn't find.