Add Nofollow Attribute To The Link To Comments Generated Thru WordPress comments_popup_link

If you are developing a WordPress theme for distribution or for your own blog and you are using the template tag comments_popup_link to display the link to normal post comments or open up comments pop up window, you would definitely like to make those links on blog home page ‘Nofollow’ as there is no need to keep them ‘do follow’, and let the search engine bot crawl them every time it crawls your home page or all important blog pages with these kind of links.

Below is a simple function attached to a WordPress filter to make all those links ‘No follow’ for the search engines like Google. Add the below code at the very bottom of your active theme’s function.php (Theme functions) and it is all.

Illustration Image:-

make comments_popup_link nofollow

What this code does is

It is simple! The function add_nofollow_to_comments_popup_link will add rel=”nofollow” to all the comment links generated by the template tag comments_popup_link, so that all the links are now nofollow.

It is tied to WordPress filter ‘comments_popup_link_attributes’ which can be used to add various attributes to the comment link generated by the comments_popup_link WordPress Template tag.

 

Leave a Reply

Your email address will not be published. Required fields are marked *