asked 8 years ago

Hi, this might not be a strictly DesignWall / Focus theme question, but it might be related somehow:

We have an RSS feed from our website (WordPress 4.5.2 Focus 1.08 theme):
This rss feed streams all our published posts.
However, recently we added a new category called “Brazil”, with posts written in portuguese. We don’t want those appearing in the RSS feed. I tried this method to exclude them in the WordPress main loop but it played havoc with the Focus front page – every post started appearing twice for some reason (even though all this code patch in functions.php was supposed to do was to EXCLUDE one category).

I also tried the plugin “Ultimate category excluder”
but in its options screen it shows a small error at the bottom: Warning: mysqli_get_server_info() expects parameter 1 to be mysqli, resource given in /var/www/ on line 93

Is this some incompatibility with Focus?

below doesn’t work either- tried this in functions.php:

* Exclude Brazil category from RSS feed

function exclude_category($query) {
return $query;

replied 8 years ago

ok will try, thanks… where whall I put this in functions.php?

Dominic Staff
replied 8 years ago

you can add the code in the bottom of the functions.php file. If you want, you can send me username & password of your site, I will check and help you add this code.

1 Answers
answered 8 years ago

Insert this code in your theme’s template functions.php file.  The functions.php file is located in the /wp-content/themes/{theme-name}/ directory.  For example, if you were using the default WordPress theme, the functions.php file would reside in the directory /wp-content/themes/default/.
If you were trying to exclude the category #5 from the RSS feed, the code would be

function exclude_category($query) {
	if ( $query->is_feed ) {
		$query->set('cat', '-5');
return $query;

add_filter('pre_get_posts', 'exclude_category');

If you want to exclude multiple categories, simply add a comma “,” then a dash “-” followed by the category ID that you want to exclude. For example:

$query->set('cat', '-5, -11, -18');

Or you can use WordPress plugin :RSS filter
you have the option to exclude categories,exclude post

Powered by DW Question & Answer Pro