#25380 closed defect (bug) (fixed)
Allow posts_per_page option for pre_get_posts action hook on feed
| Reported by: | wokamoto | Owned by: | wonderboymusic |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.9 |
| Component: | Query | Version: | 3.6.1 |
| Severity: | normal | Keywords: | has-patch needs-unit-tests |
| Cc: | Focuses: |
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
@
13 years ago
- Keywords needs-unit-tests added
- Milestone Awaiting Review → 3.9
I am going to write a few tests for this.
This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.
12 years ago
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Thanks for this, wokamoto. This sounds familiar — there may be a similar bug report I couldn't find.