PS I know there is a default follow/nofollow etc ON/OFF switch for pages and posts in the RankMath settings, but I was referring to editing those on individual basis
In other words, I realized I have a bunch of pages that I need to switch to Noindex, it would be more convenient if I could set that in ‘bulk’ – THANKS!
Hello,
Thank you for contacting Rank Math today.
I am afraid that we do not yet have bulk update options for these settings.
Even though you can toggle the index and nofollow from the Rank Math > Titles & Meta page, these settings will only take effect when creating new posts.
To workaround this, you can make use of a filter to set all the posts on the post type to index/follow like so:
/**
* Allows filtering of the robots meta data.
*
* @param array $robots The meta robots directives.
*/
add_filter( 'rank_math/frontend/robots', function( $robots ) {
global $post;
// filter for only a specific post type
if(get_post_type() == "your_post_type_name_here"){
$robots['index'] = "index";
$robots['follow'] = "follow";
return $robots;
}
return $robots;
});
Looking forward to helping you. Thank you.
I am also interested in this as I have maybe around 500 pages that have been created via a plugin that I want to add the noindex and nofollow option. How would the above work to do this in bulk for these custom page/post types?
Thanks,
Yannis
Hi Yannis,
You just need to add the above code to your theme’s functions.php file.
Just make sure to change your_post_type_name_here
with the actual post type name. If you are not sure, you can ask your theme provider.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Awesome. It was actually just over 9,000 pages that needed nofollowing and noindexing and it seems to have worked 🙂
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.