This function will run in Wordpress, but I need for it to happen just once per post
It replaces every instance of the word, but I want it to just replace the first instance. How can I fix it?
PHP:
<?php
function internal_linking($string) {
$string = str_ireplace(' texttoreplace ', ' <a href="http://www.msn.com">texttoreplace</a> ', $string);
return $string;
}
add_filter('the_content', 'internal_linking');
?>