Individual rss feed entry length for categories?

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;
}

Leave a Comment