What's WP
Our everything is about WordPress - best choice of WordPress users!
How to Exclude a Category from WordPress Homepage and RSS Feeds

How to Exclude a Category from WordPress Homepage and RSS Feeds

Since many webmasters get used to showing the latest web content on the homepage, they prefer to make the post public on the web page automatically. However, if you are one of them and only wish to showcase certain categories on the main page or RSS feeds rather than all recent posts, you are required to exclude some categories from the action.

Perhaps, there are some other reasons forcing you to do so. The following guide can make a big difference for you to exclude categories from WordPress homepage and RSS feeds in any case. We would like to brief you on several ways to achieve the goal, among which the use of WordPress plugin is valued highly in the post.

Make Use of WordPress Plugin

exclude category use pluginSince most readers prefer to solve problems with WordPress plugin, we are going to introduce two options to you, including Ultimate Category Excluder and Simply Exclude. Both plugins are designed for category exclusion and they are easy to handle. And now, let’s get started to feel the power of the selected plugins.

Ultimate Category Excluder Plugin

Ultimate Category Excluder is a powerful WordPress plugin used to exclude certain categories from homepage, RSS feeds, archives and search results. Once you take this plugin into effect, it helps you complete goals quickly and easily via an understandable dashboard. With this user-friendly plugin, you just need to check which categories should be excluded.

Here, we suggest you to install and activate Ultimate Category Excluder via your WordPress admin. Search for this plugin through plugins > Add New and enable it for your website step by step. And then, a new item called Category Exclusion is included in Settings. Click it and go to Ultimate Category Excluder options interface, which includes all categories on your website.

ultimate category excluder options

You are allowed to exclude a category from main page, feeds, archives and searches according to personal needs. For example, we plan to exclude the “Uncategorized” category from homepage and RSS feeds, and then we should check the options of “Exclude from Main Page?” and “Exclude from Feeds?” in the same row with “Uncategorized”. Finally, click “Update” button to confirm all settings.

To be honest, Ultimate Category Excluder saves you a lot of trouble to exclude categories from homepage and RSS feeds. Even for beginners, they just need to complete all processes within a few clicks.

Simply Exclude Plugin

Simply Exclude, as its name suggests, aims to making category exclusion as simple as possible. Users just need to check or uncheck the given options and determine which categories should be excluded from homepage or RSS feeds. As the way to install Ultimate Category Excluder, we would like to complete the installation via Plugins > Add New. Later, a new item called “Simply Exclude” appears on the dashboard sidebar.

Go to Simply Exclude > Settings and then come to the interface of this great plugin. There are three tabs available for you, including Taxonomies, Post Types and Users. Each tab enables you to exclude certain items from the action. Here, we would like to brief you on those tabs one by one.

simply exclude categories

Taxonomies is where to exclude certain categories and tags from various actions, including Archives, Feeds, Front/Home, Searches and Widget: Tag Cloud. Note that, the Categories section also enables you to exclude a category from WordPress list category widget.

First of all, you are required to check the “Active” option to make this section into effect and then check the “Include only” or “Exclude” option to include or exclude the item. For example, we plan to exclude categories from homepage and RSS feeds, so we are required to check the “Exclude” option next to Feeds action and Front/Home action.

Post Types is where to exclude some post types from the action, including Pages and Posts. You can exclude certain pages from searches or pages widget while exclude some posts from archives, feeds, homepage and searches.

simply exclude usersUsers is where to exclude certain user items from homepage, archives, searches and feeds. This tab is designed for webmasters who are running a multi-user website and wish to exclude web content from certain users.

To be honest, the first recommended plugin is much more suitable for people who prefer to solve problems with a few clicks. However, the second selected plugin is created for users who long for a more flexible solution to exclude certain web content from the action.

Besides Ultimate Category Excluder and Simply Exclude, there are many other choices available for you, such as Category Excluder from Theme Customizer, WP Exclude From Homepage, Simple Exclude Categories, and so on so forth. Frankly, using WordPress plugin is an effective method to exclude a category without the need of any professional skills, which is worth a shot.

Exclude a Category with Coding Stuff

If you wish to get a flexible method and have a way with coding stuff, then the following method is created for you. Here, you are required to modify some tags and lines of code to reach the target. We would like to explain the method to exclude a category from homepage and RSS feeds respectively.

Exclude a Category from Homepage

Generally, you just need to add the following code to the theme’s functions.php file and modify certain values as needed. In this way, the specific categories are excluded from your website homepage.

Go to your website backend > Appearance > Editor > Theme Functions and add the following lines of code to this file.

function exclude_category_from_homepage($query)
{
    if ( $query->is_home() )
        $query->set('cat', '-{category_id_1}, -{category_id_2}');

    return $query;
}

add_filter('pre_get_posts', 'exclude_category_from_homepage');

Note that, the {category_id_x} are the ID numbers of categories to be excluded from homepage. You are required to fill out the category ID in this field correctly. If you have no idea on each category ID number, you can fall back on the plugins, like Simply Show IDs, Reveal IDs and WP Show IDs, which are designed for displaying the ID number of categories, posts, pages, and some other content on your site. Finally, “Update” the functions.php file to confirm all changes.

Exclude a Category from RSS Feeds

The way to exclude a category from RSS feeds is similar to the above-mentioned method for category exclusion on homepage. Likewise, you are required to open the theme’s functions.php file via Appearance > Editor and add the following code to this file.

function exclude_category_from_feed($query)
{
    if(is_feed()) 
    {
        $query->set('cat', '-{category_id_1}, -{category_id_2}');
        return $query;
    }
}

add_filter('pre_get_posts', 'exclude_category_from_feed');

In this way, the included categories will never appear on the RSS feeds till you change your mind. Maybe now, you cannot wait to have a try on the above methods. If you regard the use of code as a frustrating method, you’d better select a plugin from the recommended options. If not, we suggest you to consider making a good use of code and give it a try.

Author

Lucy has been a very experienced SEOer, technical writer, web developer, c# developer since 2002. Now she owns a startup in San Francisco, CA, focusing on running a couple of blogs to share knowledge and experience with global readers and deliver exceptional results to global sponsors by leveraging the power of Internet.

Close

Want to Learn More About WordPress?

Get Our Free Themes, Plugins, Support, SEO Tips, and Other Tutorials!

Email *