While working on a recent website, I became frustrated by the lack of nofollow support in many WordPress functions. Make that, most WordPress functions.
There are a few WP functions that I wanted to add nofollow to, so here’s a list and a download link:
next_posts_link() → nofollow_next_posts_link()
When you’re in a single post, you can use next_posts_link to generate a link to the next post. The title can be the name of the next post, or something as simple as…well…”next post”. If you’re using your blog title as the anchor text, you already will have the same link coming from your archives page — and probably inside a H2, which is much more valuable. To give that link more weight, we add nofollow. If you have some other text, like “next post”, then you definitely will want nofollow.
previous_posts_link() → nofollow_previous_posts_link()
Same issues as nofollowing the next_posts_link() function.
post_comments_feed_link() → nofollow_post_comments_feed_link()
I didn’t want search engines spending their time indexing the comments feed for each post — they should be automatically checking the new comments anyway, so why have that issue arise? Nofollow it is!
comments_popup_link() → nofollow_comments_popup_link()
If you have a link to leave a comment on your archives or index page of your blog, you have a slew of links that say “leave a comment” or something similar. That’s just not great link sculpting going on there, now is it? Nofollow it is!
next_image_link() → get_next_image_link() &
previous_image_link() → get_previous_image_link()
In an attachment.php file, next_image_link() and previous_image_link() are similar to next_posts_link() and previous_posts_link() — except they provide links to the next image in the gallery, rather than the next post in the blog. I wanted to be able to have the functions return a value rather than echo one, so I added these functions that keep the WordPress structure of adding get_ before a function to represent it does the same thing.
the_category → nofollow_the_category &
get_the_category → nofollow_get_the_category &
get_the_category_list → nofollow_get_the_category_list
Added 2/20/09: I’ve modified these category functions to be nofollow. If you want to list the categories your post is in without having them followed, use these functions instead of your standard ones.
Once you download these WordPress nofollow functions, if you don’t have a functions.php file yet, rename it to functions.php and copy it to your theme’s folder. If you do have a functions.php file, copy and paste the code into the file. Then, use the nofollow versions of the functions in place of the standard versions in your theme.
Leave any questions in the comments below!