Hello,
Thank you for contacting Rank Math and bringing your concern to our attention.
You can use this code to set those filtered URLs to noindex:
add_filter( 'rank_math/frontend/robots', function( $robots ) {
$url = home_url( $_SERVER['REQUEST_URI'] );
if (strpos($url,'?filter_color=') !== false || strpos($url,'?filter_brand=')) {
$robots['index'] = 'noindex';
$robots['follow'] = 'nofollow';
return $robots;
}
return $robots;
});
Here’s how you can add a filter/hook to your WordPress site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps.
Thanks, I’m working on setting it up.
Hello,
Let us know how it goes.
Meanwhile, please don’t hesitate to get in touch if you have any other questions.
Looking 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.