Posted in WordPress · September 20th, 2011 by Kazim · Comments (5)
I was searching around internet all over for adding rel=”nofollow” to external link in my posts. Suddenly, I came over a guy he has a blog that has many external links in its post but they weren’t at nofollow attribute, that blog has PR 0 and was there for more than 2 years. He randomly added no follow to his external links of WordPress posts. He raised up with PageRank 3 within very little time. Google actually links that how much you’ve been linking externally and what sites are they, So my suggestion to you is add no follow to your blog posts. Here is how.
function add_link_attr($func='', $args='', $attr='', $imgtag=false) { $tag = ($imgtag) ? "<img " : "<a "; $tag_attr = $tag . $attr . ' '; $func_args = array(); if(!is_array($args)) { $args_array = preg_split('/[\,]+/',$args); foreach ($args_array as $arg_array) { array_push($func_args, $arg_array); } } else { $func_args = $args; } if($func) { $func_args = array_map('trim', $func_args); ob_start(); call_user_func_array($func, $func_args); $input = array(ob_get_contents()); ob_end_clean(); foreach($input as $line) { $output .= preg_replace("/$tag/", $tag_attr, $line); } echo $output; } }
<?php the_content(); ?>
with
<?php add_link_attr('the_content', 'Read more', 'rel="nofollow"'); ?>
Finally you’re done! You can now check the source of any post page that has external links.
NoFollow External Links - WordPress Plugin
Nofollowr - WordPress Plugin
April 4th, 2011 at 7:39 PM
thanks for the information, i tried this but it didn’t work!! how do i place no follow to non external links, posts links, comments, and other links?
thank you
April 12th, 2011 at 1:10 PM
Dear Done,
You want to place no follow on non external links, does this mean that you want to leave with follow to external links? Which WordPress version are you using currently?
Thanks
June 30th, 2011 at 5:06 AM
I’m afraid I don’t quite follow. What does “Copy the below code to the new line” mean?
I can’t see where I put that line of code.
Thanks
Peter
June 30th, 2011 at 10:10 PM
Dear Peter,
Put this code on new line, describing in easy words. After
Thanks
Kazim K.M
January 9th, 2012 at 12:50 PM
Really thanks, I’ve been having problem finding this and all I have to do is just to copy and paste great.