• Home
  • Cloud
    • General
    • SaaS
    • BPaaS
    • PaaS
    • IaaS
    • Other Internet Hosted Applications
      • WordPress
        • WooThemes Canvas
          • WooThemes Canvas CSS
  • About me
  • Why Badly Wired?
  • Contact

Badly Wired

Cloud solutions, technical snippets and other goodies

alan
You are here: Home / Archives for code snippet

Auto adding rel nofollow to WordPress posts

4th January 2015 by Alan Leave a Comment

From an SEO perspective, there are multiple reasons that you want to use rel=nofollow on your links.

rel=nofollow basically tells Google not to pass ‘link juice’ to the target of the link.

Originally, you would want to do that to stop passing on your link juice, when you would want to keep it for your internal links. But now there is a more compelling reason, with so many blogs effectively selling links, if your blog posts have lots of outbound links to help the reader, then Google could inadvertently think you are actually a spammy blog.

As many of my blog posts reference third party sources, I didn’t want google to get the impression that the blog posts are there just to provide SEO to someone else and get caught up as a spammy blog.

Of course, you can manually add rel=nofollow to each link in a post, but I wanted a way of just setting all links in the content of a post to be rel=nofollow.

This simple bit of code added to functions.php does the trick for me

PHP
1
2
3
4
5
6
7
8
9
//* force no follow in posts
function myfunc_nofollow($text) {
global $post;
if( is_single() ) {
$text = stripslashes(wp_rel_nofollow($text));
}
return $text;
}
add_filter('the_content', 'myfunc_nofollow');

 

 

Filed Under: SEO, Wordpress  Tagged: code snippet, nofollow, Wordpress

Categories

  • Applications
  • Cloud
    • General
    • Google Cloud
    • IaaS
    • Other Internet Hosted Applications
      • Wordpress
        • WooThemes Canvas
        • WooThemes Canvas CSS
    • SaaS
  • Code snippets
  • Discounts
  • Genesis
  • Google Apps for Works
  • Linux
  • News
  • SEO
  • Server setup
  • Services
  • Tech Tips
  • Uncategorised
  • Useful Images
  • Useful Stuff

Tags

background jobs beadcrumbs bind brandings Cache canvas Centos chrome css fail2ban Find firefox Flash fraud genesis gocardless godaddy Google google maps hackers internet explorer javascript KashFlow Linus linux Magento mapquest maps microsoft mysql news nohup php plugin plugins queens diamond jubilee replace SED SEO skype Varnish Virtualmin Webmin woothemes Wordpress

Subscribe to my Newsletter

Sign up to my occasional newsletter

 

Affiliate and Privacy Notices

This site is free to use, but hopes to cover some costs through affiliate income, some products and links are affiliates and may earn the site advertising income.

Some affiliates use Cookies to track if you purchase from them, this allows them to apportion revenue to us you will need to refer to their specific privacy notices as to how you are tracked.

This site is a participant in the Amazon EU Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.co.uk.

  • Privacy Policy
  • Account
  • Register
  • Memberships

Copyright © 2019 · Badly Wired

This website uses cookies to improve your experience. Also when you click on affiliate links those links may use Cookies to track you to be able to apportion revenue to us. We'll assume you're ok with this, but you can opt-out if you wish.Accept Read More
Privacy & Cookies Policy