Archived topic
How To Fix Excerpt Text In RSS Feed
3 replies · Started by Rachel on January 22, 2023
Hi there
I use the following snippet to add the Read more linked text to my manual excerpts on the site, but the issue is in my RSS feed which I use to send automated emails to my list - the Read more text appears after the excerpt text on the RSS post description (unlinked - see below example).
Current Snippet:
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;
if ( has_excerpt() ) {
$output = sprintf( '%1$s %3$s',
$excerpt,
get_permalink(),
__( 'Read more', 'generatepress' )
);
}
return $output;
}
RSS Feed Excerpt Text Example:
This is my manual excerpt text. Read more The post Title Of Post appeared first on Site Name.
How can I remove the read more text which appears between the excerpt and the final sentence in my RSS description?
Thanks,
Rachel
Hi there,
in your snippet, this line:
if ( has_excerpt() ) {
change to:
if ( has_excerpt() && ! is_feed() ) {
This will check if it is NOT (!) the feed, before adding your read more
Great that seems to have worked - thanks for the help David!
You're welcome