• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2966

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Subscriptions
  • Access
  • Log in

Add No Follow To External Links Dynamically

This code will add the rel="nofollow" attribute to all external links. It checks all a href links within the content area in single posts for your domain and adds nofollow when the domain doesn’t match.

Demo Video

Shows the no follow attribute added to external links.

Tested using the Genesis Sample theme by StudioPress however will work in any WordPress child theme by adding a conditional tag after the function name like this :

if ( ! is_singular('post') ) {
}

When using the code in non Genesis themes, add the PHP code to your child themes functions file and delete the single.php file.

Installation Steps – Genesis Users

There’s 2 steps :

  1. # Upload the files named single.php & nofollow.js to your child theme folder like this :
  2.  

  3. # Swap out all instances of wpsites.net in the nofollow.js to your domain.
  4.  

Download Folder

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Code written by Brad Dalton specialist for Genesis & WooCommerce.

Advertise · WPEngine · Genesis · Log in

  • Account
  • Consulting
  • Post Tags
  • Contact
  • Terms
  • Monthly Membership
  • Yearly Subscriptions
  • Log in
 

Loading Comments...