Code SEO WordPress

Nofollow SEO for your WordPress Functions

Link Condom
Pretty crude idea of nofollow, isn't it?

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:

Download the nofollow_functions.php file

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!

24 replies on “Nofollow SEO for your WordPress Functions”

Your 11 top wordpress plugins was cool I’m not 100% about this but I’ll check it out thanks for the info.

grrrrr, added the one for comments popup link to functions.php and nothing happens. There is a call to comments_popup_link function in index.php.

Using 2.7.1

Any ideas?

Awesome, thanks for this! Any way to create a new nofollow function for the “the_category”?

It would be nice if there was a easy way to nofollow the categories that posts are located in under the post title itself.

For example:

by Filed Under:


Err I just realized you can’t post code….basically the structure would be:

[Post Title]
[The Date] by [The Author] – Filed under [The Category]

I haven’t found any simple solutions yet 🙁

Zack, you’re the man!

Did you perhaps forget to update the .txt file on your website? I searched the document for nofollow_the_category() but didn’t find anything?

Here’s one I just came across for no-indexing your page 2, 3, 4 (0ff of home page). Add it to header.php

if ($pages>=2) {
echo ”;

Now your next-previous links, or if you are using pagination, will flow link juice to these deeper pages but only the post page itself gets indexed. I use no-index on archives and categories too.

Does anyone know of a way to add no follow to just the comments page itself in 2.7.1 I have tried every plugin out there and can’t find the answer. I don’t want a duplicate url. A comment url adds the word respond to the url like this
it also is adding urls with comments at the ends like this
I need a hack to fix it. Even platinum seo plugin wont work for it. This is depressing. If anyone can help me please let me know. Thanks.

Thanks a lot! I realized that many famous seo blog don’t use tags.  However, I can see you use tags without “nofollow” in your post page, can you give me some info about that?

thank u but i wonder something i heart that the next link and previous link is better for seo becasue google wants to like breadcrumbs for explore between page is it a contradiction

I just wanted to say thank you for taking the time to put it together and sharing it!

Comments are closed.