How to truncate your WordPress RSS Feed at the More Tag

The More tag is a marker you can place in your WordPress posts that breaks up the post into two sections. It’s used to manually determine where the ‘read more’ link is placed when presenting a teaser of a post. WordPress doesn’t respect the More tag in RSS feeds by default, so if your rss feed is set to full or summary, it won’t break your posts as specified by the More tag. I have tried plugins that remedy this, but they fell short so I created my own function.

Fortunately, you can alter the content of RSS content through filters. What we want to have happen is to have a post break at the More tag and set the display of a teaser link (such as “continue reading” or “read more”). The two filters that are relevant are the_content_feed and the_excerpt_rss. These filters are applied before the RSS feed is generated and after regular content filters have been applied.

If your RSS feed is set to full and you want to break the posts up at the more tag position, here is an example function you can modify and place in your ‘functions.php’ file.

[codeshower ui_state=”” language=”php” code=”%2F*%0AThis%20functions%20display%20a%20custom%20teaser%2C%20by%20finding%20the%20teaser%20content%20using%20preg_split.%20It%20then%20appends%20a%20custom%20more%20link%20and%20returns%20the%20filtered%20content%20which%20then%20will%20show%20up%20in%20your%20RSS%20feed.%0A*%2F%0Afunction%20dear_abby_rss_teaser(%20%24content%20)%7B%0A%20%20%24teaser%20%3D%20preg_split(%20’%2F%3C%5C%2Fspan%3E%2F’%2C%20%24content%20)%3B%0A%20%20%24readmore%20%3D%20’Read%20Abby%5C’s%20answer%20here’%3B%0A%20%20%24content%20%3D%20%24teaser%5B0%5D.%24readmore%3B%0A%20%20return%20%24content%3B%0A%7D%0Aadd_filter(%20’the_content_feed’%20%2C’dear_abby_rss_teaser’%20)%3B”]


  1. Chris says:

    Hi Peter, I know you’re not in the business of providing tech support, but when I add the code to my functions.php file, my site spits out this error:

    Parse error: syntax error, unexpected T_STRING in /nfs/c03/h04/mnt/168695/domains/ on line 4053

    Do you know how I might be able to fix this?


    • Peter Knight says:

      Nice website Chris. Looks like there is a typo (a missing character like ” or ; probably) somewhere in your code, what version of WordPress do you have installed? If you paste your code to modify your RSS feed in I’ll have a look.

      • Chris says:

        Thanks a lot for the help Peter! I inserted your code snippet at the bottom of my functions.php file (wp-includes/functions.php), and I’m running 3.6. Here’s the ending of functions.php: (only very slightly modified).


        • Peter Knight says:

          Hi Chris, I was wondering why the functions.php was so long. So I should have been a bit clearer in the article, but there can be multiple functions.php files throughout the codebase, the one that you can add code to is the one located in your theme folder (/wp-content/themes/your-theme/functions.php). People use that file typically, although it’s better to put a piece of code like this in a small plugin. Anyhow, you’ve added it in a core WordPress file which will cause problems (and you lose your edits on a WP upgrade). So – what I recommend is restoring this file (replace wp-includes/functions.php with a fresh copy) and using a plugin for your RSS code. Here’s a zip of how it looks as a small plugin – you can move this to your /wp-content/plugins/ directory, then activate it and check to see if you are still getting an error.

          • Chris says:

            Ah, that makes a lot of sense! I modified the first functions.php file I found, because I thought it was the only one. Just appended the code and restored the original file, and it looks like it’s working. Thanks a lot for the help!

  2. Richard says:

    Hi Peter,
    Many thanks for this helpful code. I am after something different in that I would like to maintain the “classic” the_content_feed for a full blog content feed, and create a second feed that just goes up to the more tag. I think your code will achieve the second objective but not the first. Is there any way I can add something similar directly into my new customfeed.php file, say? Any thoughts? Thank you for your wisdom here!

  3. Justin says:

    Just wanted to say thanks! The plugin still works on WordPress 4.0. I’m using a Genesis Framework child theme, and I think there’s an issue with filters in the parent theme that prevents pasting this into functions.php (in the child theme) from working. Great to have the plugin working, though. Thanks again!

  4. Thank you so much! This is exactly what I’ve been looking for all week! You should totally publish this as a plugin with wordpress, I bet there are a lot of people looking for a solution like this. Thanks again!!

Leave a Reply

Your email address will not be published.