Save 25% on Wizard’s SQL for WP w/ code: WIZARDSQL
Web Dev + WordPress + Security

The Deluxe One-Minute Dofollow WordPress Upgrade

After our previous article, we all know how easy it is to kill the default nofollow attributes that WordPress automatically injects into all commentator, trackback, and pingback links. Indeed, our original one-minute upgrade delivers dofollow links across the board, effectively passing the love juice to every type of response. Fine for some, but some need more..

In this article, we improve the original dofollow upgrade by differentiating between the three different response types. With our “deluxe” model, nofollow attributes may be removed selectively from trackbacks, pingbacks, commentator links, or any combination thereof. For example, you may remove nofollow from commentator links while dishing full juice to trackbacks and pingbacks.

Ready? Let’s do this thing..

Step 1

First, open the file wp-includes/comment-functions.php and locate the function get_comment_author_link(). In WordPress 2.0, 2.1, and 2.2, we see something similar to this:

function get_comment_author_link() {
	global $comment;
	$url    = get_comment_author_url();
	$author = get_comment_author();

	if ( empty( $url ) || 'http://' == $url )
		$return = $author;
	else
		$return = "<a href='$url' rel='external nofollow'>$author</a>";
	return apply_filters('get_comment_author_link', $return);
}

Step 2

Next, upgrade that dry, crusty default code with our juicy deluxe model:

// Deluxe One-Minute Dofollow WordPress Upgrade
function get_comment_author_link() {
	global $comment;
	$url    = get_comment_author_url();
	$author = get_comment_author();
		if ( empty( $url ) || 'http://' == $url )
			$return = $author;
		elseif ( $comment->comment_type == 'pingback' )
			$return = '<a href="'.$url.'" rel="external nofollow">'.$author.'</a>';
		elseif ( $comment->comment_type == 'trackback' )
			$return = '<a href="'.$url.'" rel="external nofollow">'.$author.'</a>';
		else
			$return = '<a href="'.$url.'" rel="external nofollow">'.$author.'</a>';
	return apply_filters('get_comment_author_link', $return);
}

Step 3

Lastly, remove any/all of the three nofollow attributes that you desire. Upload, check, and done!

Final thoughts..

Beyond the selective deliverance of piping hot G-juice, the “Deluxe One-Minute Upgrade” (hey, I had to call it something) provides complete control over the markup and presentation of commentator links, trackbacks, and pingbacks. If anything, look at this hack as a friendly way into the dark heart of the WordPress core. Use it to incorporate response-specific (X)HTML markup, CSS styles, DOM behaviors — whatever! After the customization of your nofollow strategy, the sky’s the limit!

Jeff Starr
About the Author
Jeff Starr = Creative thinker. Passionate about free and open Web.
The Tao of WordPress: Master the art of WordPress.

6 responses to “The Deluxe One-Minute Dofollow WordPress Upgrade”

  1. Chino Yray 2007/09/11 6:45 am

    why not release a better DoFollow Plugin?

  2. Avatar photo
    Perishable 2007/09/11 8:29 am

    I am considering it.. There are already ten great dofollow-related plugins available that provide a great deal of control over the nofollow-removal process. So, if I develop a dofollow plugin, I would try to focus on features that are not currently available. Perhaps today I will play around and see if anything worthwhile comes of it.
    Either way, I appreciate the suggestion!

  3. Avatar photo

    Thank you for this Upgrade. I implemented it on several blogs of mine. What I would really like is a tool to distinguish between high and low quality commentators

  4. Avatar photo

    Yes, that would be a useful feature, indeed. In your opinion, what are a few variables that could be used to determine the inherent value of commentators?

  5. relojes de pulsera 2009/02/17 5:21 am

    There are some plugins that remove nofollow after a few comments, that may be a good option for those seeking a different tool ..

  6. Avatar photo
    Jeff Starr 2009/02/17 9:41 am

    @relojes de pulsera: absolutely. Here is a complete list of all WordPress dofollow plugins. Plenty of options from which to choose. Thanks for the feedback!

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
SAC Pro: Unlimited chats.
Thoughts
Plugin updates! All of our free and pro plugins ready for WordPress 6.2.
Daylight savings is a complete waste of time and needs to be eliminated.
Got a couple of snow days here in mid-March. Fortunately it's not sticking.
I handle all email in real time as it comes in, perpetually clear inbox for years now.
Added some nice features to Wutsearch search engine launchpad. Now 21 engines!
.wp TLD plz :)
Nice collection of free SEO APIs and user-agent lookups for Googlebot, Bingbot, Applebot, YandexBot, and more.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.