#17853 closed defect (bug) (fixed)
Posts_per_page=-1 overwritten in query.php if is feed, (An ics feed needs all)
| Reported by: | anmari | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.9 |
| Component: | Feeds | Version: | 3.2 |
| Severity: | normal | Keywords: | close has-patch |
| Cc: | Focuses: |
Description
Similar to 15852, the posts_per_page argument to wp_query, is being overwritten in lines 1991 of query.php
if ( $this->is_feed ) {
$q['posts_per_page'] = get_option('posts_per_rss');
In the case of an ics feed - ALL requested posts must be returned for a complete feed, so need to be able to pass posts_per_page=-1 as with other queries in the front end.
This is in wp 3.2 RC1 and earlier.
As far as I can make out, the only way around for now is to add a post_limits filter and remove the LIMIT in the query when it is a ics feed. (ie return empty string)
While the workaround works, it would make more sense of the post_per_page argument worked as in front end queries.
Possible workaround (use in custom feed function only)
...
add_filter('post_limits', 'amr_remove_limits');
...
function amr_remove_limits () {
return ('');
// return an empty string so that NO limits are imposed in the query
}
Attachments (1)
Change History (12)
#3
@
15 years ago
I am not entirely a fan of how this works. An override should be allowable without hooking in again. I suggest it also checks whether $q['posts_per_page'] is not set before pulling from posts_per_rss.
#4
@
14 years ago
I've attached a proposed fix for this issue that would allow posts_per_page overrides on the query to function normally with feeds as with any other query.
#9
@
14 years ago
Would be great to see this patch implemented.
Note @xknown's workaround will not work. At the same $q['posts_per_page'] is over-ridden by the RSS option, it sets the $['nopaging'] to false. The upshot is that the LIMIT part of the query is still included, but with a '-1' - causing an error.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
You can also attach to the filter
pre_option_posts_per_rssand return -1 as you want.