I am trying to append a php query to the end of links from my website to a sponsor site using the_content
filter and preg_replace()
. I have tested my regex expression on regexr.com and it works. I have also used print_r()
to test that the function is being called but for some reason the links are not being changed in practice. Here is the code I am having trouble with
add_filter('the_content', 'linkAppend');
function linkAppend($content) {
global $referalString;
preg_replace('/\/\/(www|launch)?\.?(solarwinds\.com)\/[^"]*/g','$&?cmp='.$referalString, $content);
return $content;
}
If someone could point me in the right direction, or let me know where I went wrong, I would be greatly appreciate it.