Posts Tagged ‘hack’

How to Exclude Categories from RSS Feed in WordPress

November 14, 2009 |  by Design Gala  |  1 Comment

wplogo-stacked-rgbLast week I wrote about how to disable WordPress RSS feed completely from end users. Sometimes there are cases where we want posts from certain categories not to publish in RSS feed; we just wish to unpublish post in feed.

There are 2 ways to disable categories in feeds.

1. If you’re a feedburner user

You’ll have to edit the original feed source in your feedburner account like below;

http://designgala.com/feed?cat=-7&cat=-18

Above URL would exclude posts from categories with ID 7 and 18

2. From standard RSS feed

In order to use this method, you need to add following code in function.php of your active theme.

/**
* disable RSS feed
*/
function exclude_categories_in_feed($query) {
	if ($query->is_feed) {
        $query->set('cat','-7,-18'); 
return $query;
}
 
add_filter('pre_get_posts','exclude_categories_in_feed');

I hope this was short but cool wordpress hack to exclude categories from RSS feed.

An easy Hack to Disable RSS feeds in WordPress

November 7, 2009 |  by Design Gala  |  1 Comment

disable rss wordpressRSS feed is one of the best feature of WordPress for sharing post. But there are cases where feeds either have little importantce or does not have any roles to play as in static websites, CMS. For all who do not need RSS feature in WordPress it can be disabled with a little effort.

Step 1:

Create a new function in function.php located in your active theme folder like below:

/**
* disable RSS feed
*/
function wp_disable_feed() {
   wp_die( __('Sorry, no feeds available, return to <a href="'. get_bloginfo('url') .'">homepage</a>') );
}
 
add_action('do_feed', 'wp_disable_feed', 1);
add_action('do_feed_rdf', 'wp_disable_feed', 1);
add_action('do_feed_rss', 'wp_disable_feed', 1);
add_action('do_feed_rss2', 'wp_disable_feed', 1);
add_action('do_feed_atom', 'wp_disable_feed', 1);

I told you. Its very easy to disable feeds.