0

I'm trying to change the url of a link on my wordpress site thru a PHP function. So far echoing out the string url is giving me trouble.

I have the following in my PHP file.

$siteurl = site_url(); // gives me: "http://localhost/testsite"

 $teststring = "/catalog";

$entireurl = $siteurl.$teststring; //gives me "http://localhost/testsite/catalog"

function change_site($buffer) {
$in = array('<a href="http://localhost/testsite/type/combined/?case=main" title="Catalog">');
$out = array('<a href="'.$entireurl.'" title="Catalog">');
  return (str_replace($in, $out, $buffer));
}
ob_start("change_site");

Currently, the link takes on the link of another href link in the same div. (bizzare)

Theo
  • 33
  • 7

1 Answers1

0

Try this instead. You might be missing the . concatenator

$out = array('<a href="'.$entireurl.'" title="Catalog">');
Bonish Koirala
  • 641
  • 5
  • 16