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';
Leave a Reply
You must be logged in to post a comment.