PHP: change search string in Wordpress filter

Hi PHP help.

I have a Wordpress filter that redirects links on tags and redirects them to a different domain. What I want to do is get the filter to search the other domain for that word

This is what I have at the moment

[php]add_filter( ‘term_links-post_tag’, ‘replace_tag_domain’, 100 );

function replace_tag_domain( $links ) {

// What to find in the link
$find = home_url();

// What to replace it with
$replace_with = 'http://example.com';

foreach( $links as $k => $link )
// Run string replacement
    $links[$k] = str_replace( $find, $replace_with, $link );

// Return the modified tag link
return $links;

}[/php]

What I need to do is replace the word “dish” in the code below with the tag $link. Is it possible?

http://www.myweb.com/search?I_DSC=dish&I_DSC_AND=t&_ACT=search

So the $replace_with = ‘http://www.myweb.com/’;

needs to be replaced with:

http://www.myweb.com/search?I_DSC=

then the $link followed by

&I_DSC_AND=t&_ACT=search

the line:

http://www.myweb.com/search?I_DSC=$link&I_DSC_AND=t&_ACT=search

won’t work due to my terrible knowledge of php.

Is there some alternative?

Try this
[php]‘http://www.myweb.com/search?I_DSC=’ . $link . ‘&I_DSC_AND=t&_ACT=search’[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service