Let’s assume you have to add a specific link to the word “get regular updates” in any of your site or blog which might be your affiliate link. So every time you have to waste significant amount of time to replace the word with the link in WordPress. But you can repeat this task by applying a simple function in your WordPress theme. Here is the WordPress function to replace word with affiliate link. The link might be your affiliate link or any link you want. In our example we have replaced “get regular updates” by Get Regular Updates and the URL.
$replace = array(
‘check my doc’ => ‘<a href=”http://mysite.com/myafflink”>check my doc</a>’
$text = str_replace(array_keys($replace), $replace, $text);