X

How to Promote your RSS Feed on Every Post

Snippets by IsItWP

Are you looking for a way to add a link to your RSS feed at the bottom of every post? If you are looking to get some new subscribers, this is a great way to promote your feed. While there’s probably a plugin for this, we have created a quick code snippet that you can use to promote your RSS feed on every post.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function wps_promote_feed($content,$class = "promote") {
    echo $content;

    if (is_single()) {
?>
        <div class="<?php echo $class; ?>">
            <h3>Enjoyed this article?</h3>
            <p>Please consider subscribing to our <a class="feed" href="<?php bloginfo('rss2_url'); ?>" title="Subscribe via RSS">RSS feed!</a></p>
        </div>
<?php
    }
}

add_filter('the_content','wps_promote_feed');

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 6 best Stripe payment plugins for WordPress and how to create a review site in WordPress.

Comments  Leave a Reply

  1. Just wasted three hours figuring out what happened to my blog. Stops excerpts from showing and messes around with other stuff listed in functions.php too.

  2. This code changed my front page from displaying excerpts to displayng full posts.

    1. I use this code to display excerpts on my front page:


      $excerpt = get_the_excerpt();
      echo string_limit_words( $excerpt, 38 );

      function string_limit_words($string, $word_limit) {
      $words = explode(' ', $string, ($word_limit + 1));
      if(count($words) > $word_limit)
      array_pop($words);
      return implode(' ', $words);
      }

  3. and code needs to be internationalised to be able to use it for the other 52% of the internet…

  4. Just need to match your function name with your 2nd parameter $function_to_add and it works.

    1. Hi Brad, thanks for the heads up all fixed. Can’t imagine how I missed that,

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[60% OFF Today!]
[60% OFF Today!]
[10% OFF Today!]
[10% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]