Show content only to RSS feed subscribers

It doesn’t really matter if you like RSS because many people still use it on daily bases. While you can give more attention to social media which is a far more popular way of keeping in touch with your users, you shouldn’t forget about your RSS users. By taking care of your RSS feed, you will definitely attract more visitors to your website, and that’s something every admin tends to do.

There is so much you can do to improve your feed. For example, you can enable images in your feed, schedule your posts for RSS or add any RSS feed to your dashboard.

But in some cases, you will want to show specific content only to your RSS feed subscribers. Whether it is something concerning only users who will read that through RSS (maybe you are modifying only the RSS feed feature so there’s no need for showing the information to those who aren’t using the feed) or you want to build a broader RSS audience by creating a giveaway through feeds, you can easily create a shortcode which will allow you to display the content in RSS feeds only.

By doing that, you will be able to insert any extra content and wrap it in inside the shortcode in any post or page on your WordPress powered website.

Before you can use the shortcode, you will need to create one (see more details).

Create a shortcode where you will place the content for RSS feed subscribers:

  1. Open functions.php
  2. Copy and paste the following code:
  3. add_shortcode( 'feedonly', 'ilc_feedonly' );
    function ilc_feedonly( $atts, $content = null ) {
    if( is_feed() ) return '<p>' . $content . '</p>';
    else return;
    }
  4. Change the name of your shortcode if you want to (first line: ‘feedonly’)
  5. Save changes

After you have saved changes, your [feedonly] shortcode is ready to be used in posts and pages or anywhere else on your site (See how to use shortcodes in a Text Widget).

To create a specific content for your RSS feed readers, you will need to wrap that content into the shortcode. Here’s an example:

[feedonly] This text will be visible only in RSS feed [/feedonly]

If you paste this shortcode into a post, the text will be displayed in feeds only. If you open the post anywhere else, the text will be invisible. Simple as that.

If you’re going to use the shortcode on a daily basis, you should consider adding a button containing the code directly to your Text and Visual Editor.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *