-
I want to add <meta name=”robots” content=”noindex,follow” /> to urls which contains “?”
Or /shop/?shop_view*
Or /shop/page/*
Or /shop/?filter*
How to do that?
-
Hello,
Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.
You can modify and use the following filter to set the pages you want as Noindex & Nofollow: https://rankmath.com/kb/filters-hooks-api-developer/#change-robots-meta
Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope this helps. Let us know if you need any other assistance.
I am sorry I might have not understood this correctly.
If I have to add noindex nofollow to all the URLs which contains “?”
How will i integrate the code given by you in the link below.Hello,
You can add the filter like this:
add_filter( 'rank_math/frontend/robots', function( $robots ) { $url = home_url( $_SERVER['REQUEST_URI'] ); if (strpos($url,'?shop_view') !== false || strpos($url,'?filter')) { $robots['index'] = "noindex"; $robots["follow"] = 'nofollow'; return $robots; } });I hope that helps.
Thank you.
Your PHP code changes were rolled back due to an error on line 305 of file wp-content/plugins/seo-by-rank-math/includes/frontend/paper/class-paper.php. Please fix and try saving again.
Uncaught Error: Unsupported operand types in wp-content/plugins/seo-by-rank-math/includes/frontend/paper/class-paper.php:305
Stack trace:
#0 wp-content/plugins/seo-by-rank-math/includes/frontend/paper/class-paper.php(229): RankMath\Paper\Paper->advanced_robots()
#1 wp-content/plugins/seo-by-rank-math/includes/frontend/class-head.php(196): RankMath\Paper\Paper->get_robots()
#2 wp-includes/class-wp-hook.php(307): RankMath\Frontend\Head->robots()
#3 wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#4 wp-includes/plugin.php(524): WP_Hook->do_action(Array)
#5 wp-content/plugins/seo-by-rank-math/includes/traits/class-hookHello,
Please use the filter given below:
add_filter( 'rank_math/frontend/robots', function( $robots ) { $url = home_url( $_SERVER['REQUEST_URI'] ); if (strpos($url,'?shop_view') !== false || strpos($url,'?filter')) { $robots['index'] = "noindex"; $robots["follow"] = 'nofollow'; return $robots; } return $robots; });Hope this helps. Let us know if you need any other assistance.
Thanks.
Hello,
Thanks for the help, It did add the noindex nofollow in the header but was not able to remove the previous tag.
Please check the screenshot
Hello,
From your screenshot, it seems that you have duplicate meta robots generated from another plugin or your active theme.
Assuming you are using the latest version of all the plugins and the themes (please update if not yet), to determine that, please follow this troubleshooting guide:
https://rankmath.com/kb/check-plugin-conflicts/Here is a video you can follow as well: https://www.youtube.com/watch?v=FcIWRhcUP2c
Only the site admin would know and your users won’t be affected by this troubleshooting.
Let us know how this goes.
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.
The ticket ‘How to add Noindex- Nofollow to urls which contains “X”’ is closed to new replies.