Hello,
Thank you for contacting us.
You can use this filter to create a condition that would apply the noindex tag based on the URL:
https://rankmath.com/kb/filters-hooks-api-developer/#change-robots-meta
Hope this helps.
Thank you.
Thank you for your reply Prabhat Rai,
Could you please tell me how I can add the URL?
https://www.midominio.com/blog/projects/
I am not a developer.
Thank you
Hello,
You can use the filter given below in your theme/child theme’s functions.php file:
/**
* Allows filtering of the robots meta data.
*
* @param array $robots The meta robots directives.
*/
add_filter( 'rank_math/frontend/robots', function( $robots ) {
global $wp;
$url = $wp->request;
If (strpos($url, 'projects') !== false) {
$robots['index'] = 'noindex';
return $robots;
}
return $robots;
});
This will set the page to noindex.
Let us know how that goes. Looking forward to your update.
Thanks.
Hi Jaideep,
¡Bravo! It works but in the Meta, the follow appears.
http://prntscr.com/1uqbqv6
Is it possible to add noindex and nofollow?
Thanks
Hello,
Please try this code instead:
/**
* Allows filtering of the robots meta data.
*
* @param array $robots The meta robots directives.
*/
add_filter( 'rank_math/frontend/robots', function( $robots ) {
global $wp;
$url = $wp->request;
If (strpos($url, 'projects') !== false) {
$robots['index'] = 'noindex';
$robots['follow'] = 'nofollow';
return $robots;
}
return $robots;
});
I hope that helps.
Thank you.
Hello,
You’re welcome, and we’re glad that helped.
Please feel free to reach out to us again in case you need any other assistance.
We are here to help.
Thank you.
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.