Hello,
Thank you for contacting support.
Please share the exact report/error you are getting from the Google Search Console with us.
You can share screenshots using this tool: https://imgur.com/upload
We look forward to helping you.
Thanks.
There is no report error. I do not understand what you mean. You seem not to be understanding me. What I am saying is that I set the cart page to Noindex, Nofollow using rankmath, but when I inspect the page, it shows Noindex, Follow. Therefore the “NoFollow” is not being applied.
I already sent you the line of how it is showing up. This:
<meta name=”robots” content=”noindex, follow”>
When I should be seeing this:
<meta name=”robots” content=”noindex, nofollow”>
Why is it not applying the NoFollow directive?
Hello,
You can add the following filter on the website to set the URLs with the string cart
to noindex:
add_filter( 'rank_math/frontend/robots', function( $robots ) {
// Get the current page URL
$current_url = home_url( $_SERVER['REQUEST_URI'] );
// Define the string to check for in the URL
$string_to_check = 'cart';
// Check if the current URL contains the specific string
if ( strpos( $current_url, $string_to_check ) !== false ) {
// Change the robots tag to noindex
$robots['index'] = 'noindex';
$robots['follow'] = 'nofollow';
}
// Return the modified robots array
return $robots;
});
Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
We hope this helps.
Thanks.
Using Code Snippets Plugin which I use for everything else, added the code to be applied everywhere, cleared cache and viewed source code on incognito window and no change.
Hello,
Could you please share a sample URL in the sensitive data section so we can check as well?
Meanwhile, please try this filter if it sets the URL to noindex and nofollow:
add_filter( 'rank_math/frontend/robots', function( $robots ) {
if( is_cart() ) {
$robots['index'] = 'noindex';
$robots['follow'] = 'nofollow';
}
return $robots;
}, 99);
Looking forward to helping you.
This code works. Thank you so much.
Hello,
We are glad to be of help
Do you still need our assistance with anything else or can we go ahead to close the ticket?
We look forward to helping you.
Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.