Lightning Rank - Private Blog Network

  • Home
  • Done 4 You PBN Service
  • Other Services
    • Amazon Associate Audit
    • Editorial Links
    • Buy Expired Domains
  • Contact
    • Affiliates

How To Automatically Convert WooThemes HTTP Links To Affiliate Links

November 17, 2015 By Jon Gillham Leave a Comment

Recently WooThemes changed their affiliate provider to zferral which in turn changed all their affiliate links to a brand new URL structure. I have experienced this situation in the past with affiliate URLs and it can entail hours of changing all of your sites affiliate links to point to the new provider.

The solution will allow you to insert any default link to WooThemes into your WordPress content and those links will then automatically be appended with your WooThemes Affiliate ID. This is particularly good as if the URL structure of their affiliate program ever changes again in the future as you can simply re-write the php function to the new affiliate URL structure instead of having to change hundreds of links.

To achieve this we will use a WordPress filter via add_filter and simple php function that will target any http links to WooThemes within your WordPress content area and automatically convert them to WooThemes affiliate URLs.

Open You Themes functions.php and add the code below to that file.

/**
 *
 * Converts all WooThemes http links in your WordPres post and page
 * content automatically into Affiliate URLs
 *
 */

add_filter('the_content', 'woo_affiliate_links');
function woo_affiliate_links( $content ) {

	// WooThemes Affiliate URL Filter
	if ( preg_match( "/http://www.woothemes.com/i", $content, $matches ) ) {

		// WooTheme zferral.com Affiliate ID
		$woo_affiliate_id = 'YOUR AFFILIATE ID'; 

		// Replace WooThemes URLS With Affiliate Redirect
		return preg_replace( "/http://www.woothemes.com/i", "http://zfer.us/$woo_affiliate_id?d=$matches[0]", $content );  

	} else {

		// Return Content If No Affiliate URL Is Present
		return $content;

	}
}

Add Your Affiliate ID

In the function above you will need to change this line below to include your own WooThemes Affiliate ID.

$woo_affiliate_id = 'YOUR AFFILIATE ID';

Filed Under: Blog Tagged With: affiliate marketing, woothemes, woothemes affiliate, wphack

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • What It takes to get to #1 in Google
  • Private Blog Network Building Service in 2016 – Is It Still Worth The Risk?
  • UpThemes Scale Back On Theme Options Within Their WordPress Themes
  • Create A WordPress Login Form Shortcode For Your Blog
  • WooThemes Back Online After Malicious Hack & Further DDoS Attack

Our Team

Jon Gillham

Father, Husband and mechanical engineer. Jon has the easy job he builds and tests systems that Kelley, Hmd and their teams execute!
Ahmed Ali

Ahmed is the man that makes sure everything runs smoothly. A true jack of all trades he makes sure each site is built to our high standards!

Copyright © 2022 . Experts at Harnessing the Power of Expired Domains to Help You Outrank Your Competition