When optimizing your WordPress site for SEO, it is important to control what content gets indexed by search engines. Sometimes, you may want to noindex certain WordPress categories (like low-value or internal-use categories) while keeping others publicly visible in search results.
If you are using the Rank Math PRO version, you might be able to set “noindex” for some categories and “index” for others directly from the admin panel. However, in the free version of Rank Math, you cannot customize robots meta tags (like index or noindex) on a per-category or per-tag basis through the admin interface.
In this post, I will show you how to set “noindex” for specific categories using the free version of Rank Math. For this, you need to use a filter in your “functions.php” file. You can manually add a conditional “noindex” for selected categories using the following code in your theme’s “functions.php” file:
Here are the steps:
- Log in to your WordPress admin
- Go to: Appearance → Theme File Editor → functions.php
- Add the following code:
add_filter('rank_math/frontend/robots', function($robots) {
if (is_category('uncategorized') || is_category('your-category-slug')) {
$robots['index'] = 'noindex';
$robots['follow'] = 'follow';
}
return $robots;
});
In the above code, replace ‘your-category-slug’ with the slug of the category you want to set “noindex”.
To check if your “noindex” is working, open the source code of the category page and look for:
<meta name="robots" content="noindex,follow">
That’s all. Now your selected category will not be indexed by search engines.
