Hello,
Thank you for contacting Rank Math support.
If the concerned category has a common string in the URL, you can use a filter to set it to noindex
.
You can use the following filter on your website to set all the URLs with, for instance, arts
to noindex and nofollow:
add_filter( 'rank_math/frontend/robots', function( $robots ) {
$url = home_url( $_SERVER['REQUEST_URI'] );
if( (strpos($url,'arts') !== false) ) {
$robots["index"] = 'noindex';
$robots["follow"] = 'nofollow';
}
return $robots;
});
We hope this helps. Please let us know if you have further questions or concerns.
Thank you.
Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Thanks a lot.
By the way, is the below article of making any post No-index Category wise still valid and updated ?
https://rankmath.com/kb/how-to-noindex-all-posts-in-a-category/
Hello,
That method is still valid and might be preferable to the one I shared earlier, especially in a situation where the category base is stripped. Thank you for bringing it up.
Don’t hesitate to let us know if you need our assistance with anything else.
Hello,
We are glad we could address your concern.
Please feel free to create a new forum topic if you do have another question in the future.
It will be our pleasure to assist you again.
Thank you.