9 Extremely Useful RSS Tricks and Snippets for WordPress

By MildTheme
In Tutorial
May 26th, 2012
21 Comments
342 Views

RSS is one of the core feature of WordPress and every other blogging platform. It is very useful because your readers keep track of your blog updates mostly by using RSS. In this article, we will show you some of the most useful RSS hacks, tips, tricks, and snippets for WordPress.

1. RSS Only Posts

There are times when people cannot afford to have a newsletter service like Aweber, but they still want to reward their subscribers. They still want to keep an incentive for subscribers, so your count keeps growing. This trick will help you create posts that is only shown to your RSS readers.

rss_only posts

You can achieve this by downloading the plugin called Advanced Category Excluder. Once installed, you should designate a specific category where you will post your RSS only posts. You can even name the category “RSS Only”. Then you need to go to the ACE Settings in your WP-Admin Panel and click on the feature Categories. Check in all boxes like Home, Archives for “RSS Only” Category, and leave the RSS Posts blank. This means that you have excluded RSS Only from being displayed in your home page, archives, and other places except for the RSS Feeds.

This is almost like a newsletter sent to just your RSS email subscribers and feed subscribers.

2. Control When Your Posts are Available Via RSS

rss time control

There are times when you publish a post and suddenly find an error. You can go back in the admin panel and change it, but it is already published in the feeds. With this hack, you can put a delay of as many minutes as you like, so you can double check the post live.

Open your functions.php and add this code:

function publish_later_on_feed($where) {
global $wpdb;

if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate('Y-m-d H:i:s');

// value for wait; + device
$wait = '10'; // integer

// http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
$device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

// add SQL-sytax to default $where
$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
}
return $where;
}

add_filter('posts_where', 'publish_later_on_feed');

This code is adding a 10 minute delay on your post being shown on the RSS Feeds, you can change it by changing the number 10 to as many minutes as you like.

3. Insert Ads in Your RSS Feeds

Making money is the concept that everyone likes, but monetizing gets hard at times. This is just another way you can monetize by inserting ads in your RSS Feeds. Feedburner does it for you, but it is only Adsense Ads, and there is a subscriber count limit. This short snippet will help you insert ads, or anything else for that matters in your RSS Feeds.

Open your functions.php and add the following code:

<?php
function insertAds($content) {
$content = $content.'<hr />Check out Awesome WordPress Tips and Resources at <a href="http://www.mildtheme.com">MildTheme!</a><hr />';
return $content;
}
add_filter('the_excerpt_rss', 'insertAds');
add_filter('the_content_rss', 'insertAds');
?>

If you don’t have a functions.php file in your theme folder then simply create one. Once you have uploaded this file, you are now displaying ads in your RSS Feeds.

This hack uses an add_filter() function which does not modify your core files at all. Many other hacks ask you to modify your core files which is a bad idea because you will need to modify everytime when you reinstall WordPress.

4. Display Any RSS Feed on Your Blog

Display Any RSS Feed on Your Blog

There are often times when bloggers want to display RSS Feeds of other sites on their blog. Maybe it is from another blog of theirs that is related. This is when this hack comes handy because it makes your job much easier. There are several scripts and plugins that will do it for you, but you don’t need those because WordPress has this feature built in. And you should know that because you see the feeds in your Admin Panel Dashboard.

All you have to do is paste the following code where you want the feeds to be displayed. Most commonly placed in sidebar.php:

<?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://feeds2.feedburner.com/mildtheme', 5); ?>

Save the file and Upload it and you are done.

The function we used in this hack wp_rss is built in WordPress for future reference.

5. Exclude a Specific Category from RSS Feeds

Exclude a Specific Category from RSS Feeds

There are certain categories that contain maybe link love and others which most of your users are not interested in. This is the option to satisfy those users. You can exclude a specific category by using a plugin called Advanced Category Excluder, or you can do it manually by using the code below:

http://example.com/feed?cat=-5

To exclude multiple cateogries, just use the ampersand symbol:

http://example.com/feed?cat=-4&cat=-5

If you don’t want to use the plugin and don’t want to do it manually with the link. There is another way which you can use by editing your function.php. Paste the following code in it:

    function myFilter($query) {
    if ($query-&gt;is_feed) {
    $query-&gt;set('cat','-5'); //Don't forget to change the category ID =^o^=
    }
    return $query;
    }

    add_filter('pre_get_posts','myFilter');

6. Make a Separate RSS Feed for Each Category

Often times bloggers wonder how to make separate RSS feed for their category. Because sometimes your user only visits your website for the design category, but you have ten other categories that the user is not interested in. This hack will take care of this issue.

All you have to do is add the word feed in front of the category URL, and it will take you to the feed for that specific category.

7. List RSS Feeds by Each Category

Last hack shows you how you can have a separate RSS Feed. This snippet will let you list your category feeds by each category.

List RSS Feeds by Each Category

<?php wp_list_categories('feed_image=http://www.mildtheme.com/image.gif&feed=XML Feed&optioncount=1&children=0'); ?>

You must make sure to change the URL of the image because this will display RSS icon in front of each category.

8. Redirect WordPress Feeds to FeedBurner feeds.

We all want to have the most accurate subscriber count for our blogs. Feedburner provides us with a count of how many users have subscribed to the blog via feedburner feeds. Now WordPress by default has its own feeds to, so if someone types in yourdomain.com/feed then they should be sent to the WordPress version of the feed, and they can subscribe to that. But they will not be counted. One way you can solve this issue is by redirecting your WordPress feed to your FeedBurner feeds by using this short snippet of code: Paste it in your .htaccess file located in the root folder.

# temp redirect wordpress content feeds to feedburner
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteRule ^feed/?([_0-9a-z-] )?/?$ http://feeds2.feedburner.com/mildtheme [R=302,NC,L]
</IfModule>

Make sure that you change the feed url to your FeedBurner url. This can also be done with a plugin called FeedBurner FeedSmith.

9. Disable RSS Feeds in WordPress

Do you want to use WordPress strictly as a static website. Then it might make sense that you disable your RSS Feeds. You can go to the wp-settings.php and remove one code but that will be stupid because it is a core file. Instead what you should do is use the following code and paste it in your functions.php

function fb_disable_feed() {
    wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
    }

    add_action('do_feed', 'fb_disable_feed', 1);
    add_action('do_feed_rdf', 'fb_disable_feed', 1);
    add_action('do_feed_rss', 'fb_disable_feed', 1);
    add_action('do_feed_rss2', 'fb_disable_feed', 1);
    add_action('do_feed_atom', 'fb_disable_feed', 1);

21 Responses to “9 Extremely Useful RSS Tricks and Snippets for WordPress”

  1. Deirdre Cannavo says:

    Here’s some guidance from Google’s FAQ which may help:

  2. Создание сайтов says:

    I am now not certain where you are getting your information, but great topic. I needs to spend some time studying more or figuring out more. Thanks for excellent information I used to be searching for this info for my mission.

  3. search blog says:

    You are actually a just right webmaster. The site loading velocity is amazing. It kind of feels that you are doing any distinctive trick. In addition, The contents are masterpiece. you’ve performed a great job in this matter!

  4. burberry outlet online says:

    Hi to every body, it’s my first go to see of this weblog; this weblog consists of remarkable and in fact excellent stuff in support of visitors.

  5. Boston SEO says:

    i would comparable to bookmark the summon hence i can extend at this point yet again to recite you, as you have made a magnificent employment. groceries processor

  6. money says:

    Wow, amazing blog layout! How lengthy have you been running a blog for? you made blogging look easy. The total look of your web site is wonderful, let alone the content material!

  7. 5Linx Scam says:

    Between me and my husband we’ve owned more MP3 players over the years than I can count, including Sansas, iRivers, iPods (classic & touch), the Ibiza Rhapsody, etc. But, the last few years I’ve settled down to one line of players. Why? Because I was happy to discover how well-designed and fun to use the underappreciated (and widely mocked) Zunes are.

  8. Hard KNight Reviews says:

    This nice summary assited me very much! Bookmarked your site, extremely interesting categories everywhere that I see here! I really appreciate the information, thanks.

  9. Matthew C. Kriner says:

    Don’t understand most part of it, but the gist was very exhilirating. I wouldn’t mind having a few of those in my life.

  10. üsküdar bosch servisi says:

    Just added this blog to my favorites. I enjoy reading your blogs and hope you keep them coming!

  11. wet pussy says:

    Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how could we communicate?

  12. Public Enemy says:

    I’ll gear this review to 2 types of people: current Zune owners who are considering an upgrade, and people trying to decide between a Zune and an iPod. (There are other players worth considering out there, like the Sony Walkman X, but I hope this gives you enough info to make an informed decision of the Zune vs players other than the iPod line as well.)

  13. mayan calendar says:

    I don’t commonly comment but I gotta state regards for the post on this one :D.

  14. Public Enemy says:

    If you’re still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you’ll know which is right for you.

  15. hard knight says:

    Thank you a bunch for sharing this with all folks you actually recognise what you’re talking about! Bookmarked. Kindly additionally visit my site =). We will have a link change agreement between us

  16. running shoes says:

    You really make it seem so easy together with your presentation but I in finding this matter to be really one thing that I think I’d never understand. It sort of feels too complex and very wide for me. I’m looking forward on your subsequent post, I will attempt to get the grasp of it!

  17. bayan escort says:

    I’ll gear this review to 2 types of people: current Zune owners who are considering an upgrade, and people trying to decide between a Zune and an iPod. (There are other players worth considering out there, like the Sony Walkman X, but I hope this gives you enough info to make an informed decision of the Zune vs players other than the iPod line as well.)

  18. RIBO make money online says:

    A foolish consistency is the hobgoblin of little minds -Ralph Waldo Emerson

  19. Olin Lubell says:

    How we make own internet site pls tel me

facebook comments: