Forum Moderators: coopster

Message Too Old, No Replies

string replace function and wordpress

         

dave1236

3:42 pm on Jul 20, 2011 (gmt 0)

10+ Year Member



All:

I am in the midst of transitioning a self build affiliate rewards site to wordpress.

previously, i had used the following code to append the user's name to the link:

<a href='$link".str_replace("tracking",$_SESSION['tracking'],$idcode)."' target='_blank'><img src='$image'/></a>

where the link was the destination. I am unsure how to accomplish the same thing in wordpress, specifically around which worpdress files to modify.

any thoughts/suggestions are appreciated.

Best,

dave

rocknbil

4:13 pm on Jul 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The best I can give you without more information is that this is all done in the theme - do not mod the core WP files as they will be overwritten when the next update is deployed (which is like once or twice a month these days . . . )

That being said, you will most likely find, in your theme, either 1) calls to the_permalink() (or get_permalink() - get_... allows you to store it in a variable, the_ . . . just outputs it) or one of it's related WP functions, or 2) custom link functions in functions.php in your theme. That is where you'd look.

Given your above scenario, you could (probably?) do

$link = $get_permalink(); // current post
$link = get_permalink($id); some other post identified by $id

and apply your replacement to $link before outputting it.

If that doesn't address it you can also ask in the WordPress forum [webmasterworld.com].

the_permalink() [codex.wordpress.org]
get_permalink() [codex.wordpress.org]