2

I have two RSS feed on my Wordpress blog:

  1. mydomain.com/feed/
  2. mydomain.com/feed/anotherfeed/

Is it possible to set different items limits on these? I want to show 10 items for the first feed, but the second I want to show 30 items.

Thanks in advance

1 Answer 1

1

Sure, you can. First create the feed as per codex:

function anotherfeed_init(){
    add_feed('anotherfeed');
}
add_action('init', 'anotherfeed_init');

Now, change the post count for this particular feed:

function anotherfeed_post_count( $query ) {
    if( $query->is_main_query() && is_feed('anotherfeed') )
        $query->set( 'posts_per_rss', 30 );
}
add_action( 'pre_get_posts', 'anotherfeed_post_count' );
6
  • Where do you suggest I should place the anotherfeed_post_count function? (In which file) May 20, 2016 at 10:49
  • Both go in functions.php
    – cjbj
    May 20, 2016 at 10:56
  • Note that the first function will need a callback to achieve the kind of feed you want to display there. That's why I included the link to the codex.
    – cjbj
    May 20, 2016 at 10:58
  • Maybe better add that to a custom plugin. Feeds should not be feed-dependent.
    – kaiser
    May 20, 2016 at 11:16
  • @kaiser You mean theme dependent? That's true.
    – cjbj
    May 20, 2016 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.