How can I completely disable the limit on feed items in my RSS feed that WordPress generates? I know you can modify the limit but I want to programmatically disable the limit completely.

3 Answers 3


Right now, as wp-includes/feed-rss2.php is written, there are no ways of doing such thing by using a feed-page-specific hook or filter, so you have to either:

  1. Edit this file manually (which will be broken after every update)
  2. Make a page template with the same content and changing the query arguments before the loop runs (will generate different URLs, not a good choice but it works as expected)
  3. Alter query arguments if the page is a feed. (By using a general hook, like pre_get_posts)

I will explain the 3rd way:

function feed_unlimited_posts( $query ){
            $query->set( 'posts_per_page', -1 );
       return $vars;
add_action( 'pre_get_posts', 'feed_unlimited_posts' ); 

Please Note: I haven't done testing on this piece of code, if you did and it worked, please suggest an edit. Thanks.


Use pre_get_posts to alter the query.

For a feed you need to set posts_per_rss. "-1" for unlimited didn't worked for me, so I just used a large number (feeds are always paged, if I see it correctly).

add_action( 'pre_get_posts', 'custom_feed_set_posts_per_rss' ); 

function custom_feed_set_posts_per_rss( $query ){
            $query->set( 'posts_per_rss', 1000 );

This is a sample of generating RSS in a template style.

Template Name: Article Feed
$numposts = 10; // number of posts in feed
$posts = query_posts('showposts='.$numposts.'&cat=3');
$more = 1;

header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true);
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';

<rss version="2.0"
    <?php do_action('rss2_ns'); ?>
    <title><?php bloginfo_rss('name'); wp_title_rss(); ?> - Article Feed</title>
    <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    <link><?php bloginfo_rss('url') ?></link>
    <description><?php bloginfo_rss("description") ?></description>
    <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
    <?php the_generator( 'rss2' ); ?>
    <language><?php echo get_option('rss_language'); ?></language>
    <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
    <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
    <?php do_action('rss2_head'); ?>
    <?php while( have_posts()) : the_post(); ?>

        <title><?php the_title_rss(); ?></title>
        <link><?php the_permalink_rss(); ?></link>
        <comments><?php comments_link(); ?></comments>
        <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
        <dc:creator><?php the_author(); ?></dc:creator>
<?php the_category_rss(); ?>
        <guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php if (get_option('rss_use_excerpt')) : ?>

        <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>

        <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
    <?php if ( strlen( $post->post_content ) > 0 ) : ?>

        <content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>
    <?php else : ?>

        <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
    <?php endif; ?>
<?php endif; ?>

        <wfw:commentRss><?php echo get_post_comments_feed_link(); ?></wfw:commentRss>
        <slash:comments><?php echo get_comments_number(); ?></slash:comments>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>

    <?php endwhile; ?>


In this code the no. of post is limited to 10 of one particular category. I hope you need to work around in order to fulfill your need.

If you also generate your own query (possibly using wp_query) and then use the returned array to fill the fields for the RSS

For reference: Digging WP's article on customizing RSS feeds

P.S: code not tested.

  • It is not necessary to create a new feed include markup. A change of the query for the feed is enough and makes not necessary to maintain the feed markup.
    – bueltge
    Sep 25, 2017 at 7:21

Your Answer

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

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