-
Hello i just switched to rankmath today from yoast and i want to noindex all the post in a particular category. this setting was not available in yoast but while searching the web i found out that they were able to solve this issue for someone else in support, they came up with a php code that solved the problem and i am hoping i can get a code that will work here.
This is the code that worked with yoastadd_filter( ‘wpseo_robots’, ‘wpseo_robots’ );
/**
* Filter: ‘wpseo_robots’ – Allows filtering of the meta robots output of Yoast SEO.
*
* @param string $robotsstr The meta robots directives to be echoed.
* @return string
*/
function wpseo_robots( $robotsstr ) {
if ( is_single() && in_category( 1191 ) ) {
return ‘noindex,follow’;
}
return $robotsstr;
}Where “1191” is the category tag
but when i swithced to rankmath the noindex tag on the post disappeared ie. the code stopped working, i will be grateful if you can come up with a solution that works for me.Thanks
Warm regards
The ticket ‘how to noindex all posts in a category’ is closed to new replies.