Make blogroll links no-follow?
-
16-10-2019 - |
Question
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');
Solution
I know of three ways around this and unfortunately they all suck:
- Hack a core file
- Use a plugin
- Temporarily turn off scripgs in your browser and change them in the edit links section.
OTHER TIPS
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange