How to Exclude Specific Categories from WordPress RSS Feed

Do you want to exclude specific categories from RSS feed on your WordPress site? Many site owners use some categories for content that they don’t want to appear in the RSS feed of their site. In this article, we will show you how to exclude… Read More »

The post How to Exclude Specific Categories from WordPress RSS Feed appeared first on WPBeginner.

Do you want to exclude specific categories from RSS feed on your WordPress site? Many site owners use some categories for content that they don’t want to appear in the RSS feed of their site. In this article, we will show you how to exclude specific categories from WordPress RSS feed.

exclude category exclude specific category RSS feed feed

Method 1: Exclude Specific Categories from WordPress RSS Feed Using Plugin

First thing you need to do is install and activate the Ultimate Category Excluder plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation you need to visit Settings » Category Exclusion to configure plugin settings.

Category excluder

The settings page will display all categories on your WordPress blog with options to hide them from front page, RSS feeds, archive pages, and search results.

Simply select the exclude from feed box next to the categories that you want to exclude from your RSS feed.

Don’t forget to click on update button to save your settings.

That’s all, posts filed under your selected categories will disappear from your WordPress RSS feed.

Method 2: Manually Exclude Specific Categories from WordPress RSS Feed

This method requires you to paste code in your WordPress files. You can use this method if you are comfortable with pasting code snippets from web into WordPress.

You need to add this code to your theme’s functions.php file or a site-specific plugin.

function exclude_category($query) {
	if ( $query->is_feed ) {
		$query->set('cat', '-5, -2, -3');
	}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

This code simply excludes categories that match the given IDs. Simply replace the category IDs in the code with the IDs of categories that you want to exclude.

See our guide on how to find category IDs in WordPress.

If you just want to exclude a single category, then change the code like this:

function exclude_category($query) {
	if ( $query->is_feed ) {
		$query->set('cat', '-15');
	}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

Replace -15 with the ID of category that you want to exclude from RSS feed.

We hope this article helped you learn how to exclude specific categories from WordPress RSS feed. You may also want to see our list of 10 most wanted category hacks and plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Exclude Specific Categories from WordPress RSS Feed appeared first on WPBeginner.

How to Fix WordPress RSS Feed Errors

Are you encountering a RSS feed error on your WordPress site? Recently one of our readers asked us how to fix WordPress RSS feed errors. There are multiple type of RSS feed errors and they can be caused by changes in plugins and themes. In… Read More »

The post How to Fix WordPress RSS Feed Errors appeared first on WPBeginner.

Are you encountering a RSS feed error on your WordPress site? Recently one of our readers asked us how to fix WordPress RSS feed errors. There are multiple type of RSS feed errors and they can be caused by changes in plugins and themes. In this article, we will show you how to find and fix WordPress RSS feed errors.

WordPress RSS feed error

Most Common WordPress RSS Feed Errors

Most common WordPress RSS feed errors are caused by poor formatting. WordPress outputs RSS feeds in XML which is a strict markup language. A missing line break or an extra tab can break your RSS feed.

The RSS error message will look something like this:

XML Parsing Error: XML or text declaration not at start of entity
Location: http://example.com/feed
Line Number 2, Column 1:

Depending on what browser you are using, your RSS feed error message may vary.

You can also see this error message when visiting your feed in a browser.

Warning: Cannot modify header information – headers already sent by (output started at /home/username/example.com/wp-content/themes/twentysixteen/functions.php:433) in /home/username/example.com/wp-includes/pluggable.php on line 1228

If you are using FeedBurner, then your errors may look different.

Having said that, let’s take a look at what causes these RSS feed errors and how to fix them.

Manually Fixing RSS Feed Errors in WordPress

The most likely reason for your RSS feeds to show error is poor formatting. This poor formatting can be caused by a blank space after closing php tag in a plugin or in your theme’s functions.php file.

If you recently added a code snippet to your theme or child theme‘s functions.php file. Then you need to edit your functions file.

If there is a closing php tag at the end of your functions file, make sure that there is no extra space or line breaks after it.

Ideally, the closing PHP tag is not required at the end of the file. This is why it would be best if you remove the closing php tag altogether.

This should fix the problem in most cases. However, if it does not fix your RSS feed error, then continue reading.

Fixing WordPress RSS Feed Errors Using Plugin

First thing you need to do is install and activate the Fix My Feed RSS Repair plugin. Upon activation, simply go to Tools » RSS Feed Fix page.

Fix RSS feed button

Click on the Fix feed button and that’s all.

You can now visit your feed in a browser window or test it with a feed validator tool.

We hope this article helped you fix WordPress RSS feed errors on your site. You may also want to take a look at our guide on how to make separate RSS feed for each category in WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Fix WordPress RSS Feed Errors appeared first on WPBeginner.