Skip to content

Instantly share code, notes, and snippets.

@nciske
Created August 10, 2012 21:04
Show Gist options
  • Save nciske/3317933 to your computer and use it in GitHub Desktop.
Save nciske/3317933 to your computer and use it in GitHub Desktop.
Truncate WordPress RSS feed at <!--more--> tag
/*
http://www.peterrknight.com/how-to-truncate-your-wordpress-rss-feed-at-the-more-tag/
This functions display a custom teaser, by finding the teaser content using preg_split. It then appends a custom more link and returns the filtered content which then will show up in your RSS feed.
*/
function custom_rss_teaser( $content ){
$teaser = preg_split( '/<span id\=\"(more\-\d+)"><\/span>/', $content );
$readmore = '<p><a href="'.get_permalink().'">Read More</a></p>';
$content = $teaser[0].$readmore;
return $content;
}
add_filter( 'the_content_feed' ,'custom_rss_teaser' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment