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

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full 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

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.