• Hi,

    Is there a way to override the custom excerpt and make the RSS excerpt shorter? The reason for this is because I have a shortcode at the end and I would not like that to appear in RSS emails. I’m using Mailchimp.

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    The plugin will use your manually created excerpt if you have one–it looks like that’s the case on your site, comparing the front page with the linked post. Do you add the shortcode to the manual excerpt on the post editor screen, or do you have a function which adds the shortcode using code?

    If it’s the former, you can add some code to your site to remove the shortcode from your RSS excerpts, for example:

    
    add_filter( 'the_excerpt_rss', 'prefix_remove_shortcode_excerpt' );
    /**
     * Strips shortcodes from manual excerpts in RSS feeds.
     *
     * @param string $excerpt
     * @return string
     */
    function prefix_remove_shortcode_excerpt( $excerpt ) {
    
    	return strip_shortcodes( $excerpt );
    }
    

    I haven’t tested this, but it’s similar to what the plugin does when it’s creating its own excerpt (if the user has not provided one). If you are adding the shortcode with your own code/function, you’ll want to add a conditional to not add it in an RSS feed.

    You can add this code to your theme’s functions.php file or wherever you add custom code snippets–just make sure your files are backed up and please practice safe coding.

    Thread Starter lushtoblush

    (@lushtoblush)

    Hi Robin,

    Thanks for getting back to me. I was trying to avoid editing the functions file. Thanks anyway!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Override Custom Excerpt’ is closed to new replies.