Hello,
Thank you for your query and we are so sorry about the trouble this must have caused.
I have modified the code a bit to include add-to-cart
query URLs. Please refer to this code below:
add_filter('rank_math/frontend/robots', function ($robots) {
$url = home_url($_SERVER['REQUEST_URI']);
if ((strpos($url, '?add_to_wishlist=') !== false) || (strpos($url, '?add-to-cart=') !== false)) {
$robots["index"] = 'noindex';
$robots["follow"] = 'nofollow';
}
return $robots;
});
Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.
Hello there.
Thank you for help.
Hello,
Glad that helped.
If you have any other concerns, please don’t hesitate to contact us anytime to assist you further.
Looking forward to helping you.
Thank you.