I know how to retrieve the rss2 feed from a category in wp, namely adding /feed
behind the category name. However when I do this, not all entries from that feed are included in the rss, this is because I set the feed restriction to be 50 at the admin backend.
I would like to know if a feed length could be set indiviually for each category/feed programatically.
I could not find any api settings for the size of the feeds … any help is welcome here.
Thanks for your help.
You should be able to use pre_get_posts
and set the posts_per_page
to 50 conditionally (on being feed for categories). Unfortunately there is this unresolved trac ticket.
The only work-around is to do hook into post_limits
and replace the LIMIT
part of the SQL query directly.
add_action('post_limits','wpse71759_category_rss_limit',10,2);
function wpse71759_category_rss_limit($limit, $query){
if( $query->is_feed() && $query->is_category() ){
$paged = $query->get('paged') ? (int) $query->get('paged') : 1;
$per_page = 50;
$page_start = ($paged-1)*$per_page;
return "LIMIT $page_start, $per_page";
}
return $limit;
}