Paulund
2012-03-30 #wordpress

RSS Feed Content Only Wordpress Shortcode

The RSS feed is a very important tool for any blogger, it allows people to always stay up to date with your latest posts on your blog. The RSS feed is still an important tool to stay up to date with any blog, even with social media becoming so large. The RSS feed allows you to send either an excerpt of your post or the entire post in the feed reader. But if you are displaying the entire post in your reader then there is no need to go to your site. If the visitor never goes through to your site and just reads your content in the reader then this can be a problem for websites that rely on visitor impressions for advertisements, this would mean they are losing impressions by people just reading the RSS feed. If this is a problem for you then you can add content to the end of the RSS feed content to try and get people to visit your site. With Wordpress you can use a shortcode in your normal posts for RSS only content, below is a Wordpress snippet to use for this functionality. Add the following into your functions.php file to create the shortcode.

function rssonly_content( $atts, $content = null) {
	if (!is_feed()) return "";
	return $content;
}
add_shortcode('rssonly', 'rssonly_content');

Now we can use this in the content of your posts, at the end of your posts put the following shortcode.

[rssonly]Thanks for reading this RSS post, please visit http://www.paulund.co.uk to view more useful snippets.[/rssonly]

When this post is published on your blog you won't see this content but if you go to your RSS reader you will see this content at the end of the post.

UpChecker

Reliable uptime monitoring and instant alerts for any website downtime.

  • Uptime Monitoring
  • Performance Monitoring
  • SSL Certificate Alerts
  • Domain Monitoring
  • DNS Checker
  • XML Sitemap Monitoring