Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
No Result
View All Result

Quick and Easy Way to Exclude Specific Categories from Your WordPress RSS Feed, Front Page, Archive Pages, and Search Results

February 16, 2017
in Tutorials
0 0
Share on FacebookShare on Twitter

Have you ever wanted to exclude some specific categories from RSS feed on your WordPress site? Sometimes webmasters need to exclude some categories of posts from showing up within their website RSS feed. In this article, we will show you how to exclude specific categories from WordPress RSS feed.

1. First Easy Method – Plugin Approach

Using the plugin approach, what you need to do is to install and activate the Ultimate Category Excluder plugin. Upon activation, you need to visit Settings » Category Exclusion to configure plugin settings. The settings page of the plugin shows all categories on your WordPress blog with options to hide them from front page, RSS feeds, archive pages, and search results.

Once you are on the setting page, simply select the exclude from feed box next to the categories that you want to exclude from your RSS feed. Remember to click on the update button to save your changes. That’s all, posts filed under your selected categories will disappear from your WordPress RSS feed.

2. Coding Approach

This approach of preventing certain categories from showing up in your WordPress RSS feed involves making changes to your theme file. With this method, if you change the theme of your website you have to make sure the changes are carried over. In this method we will make a change in the functions.php file. This files contains most of the methods and filter callbacks used to render your theme.

// Function to exclude certain categories from your WordPress RSS feed
function exclude_category($query) {
  if ( $query->is_feed ) {
    $query->set('cat', '-5, -2, -3');
  }
  return $query;
}

// add the filter hook
add_filter('pre_get_posts', 'exclude_category');

The 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. To find the category ID if your post, visit the category page and view the URL of the category detail page to retrieve it. If you just want to exclude a single category, then change the code to use a single ID.

ShareTweetPin
Previous Post

Using fail2ban to Secure WordPress by Automatically Blocking Repeated Login Attempts

Next Post

How to Include Category and Subcategory in WordPress URLs

Next Post

How to Include Category and Subcategory in WordPress URLs

You might also like

Mint Linux vs Ubuntu: Which is Right For You?

Mint Linux vs Ubuntu: Which is Right For You?

March 12, 2022
Net Neutrality: What is it and Why Should You Care?

Net Neutrality: What is it and Why Should You Care?

March 12, 2022
Solid State Drives – Why You Should Buy One Today

Solid State Drives – Why You Should Buy One Today

March 12, 2022

Machine Learning Algorithms Every Beginner Should Know

January 25, 2022
What Is the log4j Vulnerability, log4shell, an Example Step-By-Step Exploit and How to Fixed It

What Is the log4j Vulnerability, log4shell, an Example Step-By-Step Exploit and How to Fixed It

December 11, 2021
Simple Video Call integration into Website with Jitsi

Simple Video Call integration into Website with Jitsi

May 26, 2020
  • Terms of Service
  • Privacy Policy
  • Careers

© 2021 Dotlayer.com

No Result
View All Result
  • About Us
  • Advertise
  • Blog
  • Careers
  • Contact
  • Contact Us
  • Get Featured
  • Home Layout 1
  • Home Layout 2
  • Home Layout 3
  • Privacy Policy
  • Security
  • Services
  • Subscribe To Dotlayer
  • Terms of Service
  • Write For Us

© 2021 Dotlayer.com

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In