Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I add a nofollow option to my blogroll links editor?

Attempted to just type "nofollow" into the "rel" input box, but its auto deleted onblur.

If I turn javascript off (thanks to Matt's suggestion below), It works, but when I check the source on my site, the rel attribute looks like this...

rel="nofollow"onclick="javascript:pageTracker._trackPageview('/outbound/blogroll/www.site.com');

share|improve this question
    
Are you just trying to nofollow certain links, or add a nofollow across the board? Its simple enough to filter the output of wp list bookmarks if that meets your needs... –  goldenapples Dec 9 '10 at 1:51
    
all my blogroll links need to be nofollow –  Scott B Dec 9 '10 at 1:54

2 Answers 2

up vote 2 down vote accepted

I know of three ways around this and unfortunately they all suck:

  1. Hack a core file
  2. Use a plugin
  3. Temporarily turn off scripgs in your browser and change them in the edit links section.
share|improve this answer
    
Of those, I like #3 best –  Scott B Dec 9 '10 at 1:55
    
How difficult would it be to add an option for "nofollow" to the Link editor's existing "Link Relationship(XFN) options list? –  Scott B Dec 10 '10 at 17:09
    
I think that's worthy of a new question. It would be possible assuming theres a way to hook into it. I don't know how but someone on here might. –  matt Dec 10 '10 at 17:36

You can filter your blogroll to make all links nofollow with a function like this:

function nofollow_blogroll( $html ) {
    // remove existing rel attributes
    $html = preg_replace( '/\s?rel=".*"/', '', $html );
    // add rel="nofollow" to all links
    $html = str_replace( '<a ', '<a rel="nofollow" ', $html );
    return $html;
}
add_filter( 'wp_list_bookmarks', 'nofollow_blogroll' );

If you need to do it on a case-by-case basis, though, you're probably stuck with some hacks like @matt pointed out.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.