• I would like to add something additional at the end of the link when generating the html. (I am reviewing flash games, and would like to create a page with the actual game on a page with similar URL. So example.com/bloons would review the game, and example.com/game-bloons would be a page to play the game.)

    this is the effect I am going for, even though this code doesn’t work:

    <a href="<?php str_replace(".com/", ".com/game-", the_permalink()) ?>">link</a>

    i tired turning the_permalink() into a string but I can’t seem to do that. (I am very new to php and wordpress and programming in general). Any ideas on how to accomplish this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The the_permalink() function will print the output before you can perform anything so try uses get_permalink() function instead.

    str_replace(".com/", ".com/game-", get_permalink($post->ID));
    Thread Starter mexsillus

    (@mexsillus)

    AWESOME, thank you chaoskaizer, that did it.

    here is the final code for anyone wondering:

    <?php $urlVar = str_replace(".com/", ".com/game-", get_permalink($post->ID))?>
    <a href="<?php echo $urlVar ?>" rel="bookmark">play</a>

    MAzCastro

    (@fmacastro)

    I had a similar problem and this post helped me fixing it.

    Thanks!

    MAC ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘alter the_permalink() output’ is closed to new replies.