-
Hello.My website is listing directory . Search function is noindex , follow . How can i do noindex nofollow ?
Search url : view-source:https://publicitesentreprise.fr/?s=avocats®ion=45993
I want to do : noindex,nofollow”
Thanks
-
Hello,
Thank you for contacting the support.
To
nofollow
the search result page, you’ll have to add a custom filter.You can add the below filter to the website and see if it gives you the desired output:
add_filter( 'rank_math/frontend/robots', function( $robots ) { $current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; var_dump($current_url); if(false === strpos($current_url, 'publicitesentreprise.fr/?s=')) return $robots; $robots["follow"] = 'nofollow'; return $robots; });
You can follow this guide to add the filter to the website:
https://rankmath.com/kb/wordpress-hooks-actions-filters/Hope this helps.
Thank you.
Can i add this with Code Snippets Plugin ?
Also i need only for my search pages ,
like : https://publicitesentreprise.fr/?s=avocats®ion=45993
i will install plugin and add your code , that’s all ? ThanksHello,
Yes, you can use the Code Snippets plugin and add the code I shared previously and see if that gives you the desired output.
The code I shared would only affect the search page as it checks for the combination of the domain name followed by the
?s=
parameter.Let us know how that goes.
Thank you.
It works for my search but how can i nofollow these : https://publicitesentreprise.fr/search/search_term_string%26sehir%26sehir%3D%26sehir%3D%26sehir%3D%26sehir%3D%26sehir%3D%26sehir%3D?cat_id&sehir?cat_id&sehir=
Because google search console giving errorShould i noindex / nofollow search terms?
Hello,
please replace the previous function with the following one:
add_filter( 'rank_math/frontend/robots', function( $robots ) { $current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; var_dump($current_url); if(false === (strpos($current_url, 'publicitesentreprise.fr/?s=' ) || strpos($current_url, 'publicitesentreprise.fr/search/search_term_string' ))) return $robots; $robots["follow"] = 'nofollow'; return $robots; });
Hope that helps. If you have questions, do not hesitate to ask.
what’s difference? Previous code worked for me.
Oh you added term string 🙂 Thanks. Is there any problem if i nofollow term strings ?
Hello,
Can you please let us know which error are you referring to here? I checked the affected URL and I can see that the actual query parameter is your website’s title and the nofollow is not applied to your robots meta tag.
We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
We really look forward to helping you.
Search function is nofollow right now but search_terms is not.
Like this url : https://publicitesentreprise.fr/search/%7Bsearch_term_string%7D%26sehir%3D%26sehir%3D%26sehir%3D%26sehir%3D%26sehir%3D%26sehir%3D%26sehir%3D&sehir=&sehir=&sehir=&sehir=?cat_id=
I’m using snippet plugin for add code.Hello,
I have modified the filter code a bit. Please check from your end if it’s working.
Looking forward to helping you on this one.
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 ‘search nofollow’ is closed to new replies.