Quick Tut: Replace Automatically Words in Your Blog With Affiliate Links
I am sure most of us making money with their blogs through affiliate marketing and the most important part of affiliate marketing is promoting affiliate links within our blog posts.
But how do you put the links?
Some of use may use specialized affiliate marketing WordPress plugin like Ninja Affiliate and SEO Smart links. Another option is to put it manually in every blog posts. To be honest, the latter is time consuming and hard for us to maintain it.
Reason?
What if the company behind a product that you actively promote all over your blog decide to change the affiliate link? It will definitely consume a lot of your time to change edit the links. The worst part, you may miss some of the links and this means loss of income.
So, for today quick tut, I’ll guide you how to replace automatically words in your blog with affiliate links. With this tutorial, if there is need to edit the affiliate links, you just need to head to one single file and edit it. Once you have done, all the affiliate links that you put all over your blog will change accordingly and effectively.
Simply paste the code below into your functions.php file.
function replace_text_wps($text){
$replace = array(
// 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
'thesis' => '<a href="http://mysite.com/myafflink">thesis</a>',
'studiopress' => '<a href="http://mysite.com/myafflink">studiopress</a>'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
add_filter('the_excerpt', 'replace_text_wps');After you have pasted the code in the correct file, make sure you edit the code under // ‘WORD TO REPLACE’ => ‘REPLACE WORD WITH THIS’ appropriately.
After you edited the code above, your blog is now ready with affiliate links. Have fun!
Credit: WP Snipp
Affan Ruslan
How if u got hundreds of affiliate links?
Will that affect your blog performance etc?
Helmi Asyraf
Easy. Just need to add additional line which similar to the lines for StudioPress and Theses above.