Support » Plugin: Amazon Link » Template keywords aren't replaced

  • Resolved SpeedUp



    I installed Amazon Link, but neither the previews nor inserted links in product posts are working.

    Problem is, the keywords, e.g. %TITLE% aren’t replaced. Could it be some php settings problem?

    For example. if I Insert a normal image link this will be shown:


    The iframe doesn’t work either – the iframe says that the server could not be found. The url is like the following:

    `…… ‘

    Any Ideas for me?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author paulstuttard



    That’s pretty odd!

    Can you tell me what version of WordPress, Amazon Link and PHP you are using?

    Can you also post the shortcode you are using in your post so I can try and recreate the problem.



    Hi Paul,

    my php version is (excerpt from phpinfo()):

    PHP Version 5.2.6-1+lenny16

    I tried different versions of the Amazon Link Plugin. First I started out with the one from the repository (3.0.4). Because this one didn’t seem to work I downloaded the most recent version (3.1.0-rc3).

    WordPress: 3.5.1 german version

    I tried several hours to find out why this is happening, but wasn’t successful. Could you tell me in which file the replacement of the keywords is done?

    I also tried several shortcodes, but no one worked:

    [amazon template=iframe image&chan=default&asin=B008R9JVPG]
    [amazon asin=0893817449&text=Static Link]
    [amazon template=image&chan=default&asin=B008R9JVPG]
    Plugin Author paulstuttard



    Sorry it’s not working for you.

    The template is parsed in the file amazon-link/include/amazonSearch.php in the function parse_template. It is done very differently in version 3.1.0 from version 3.0.4 so I suspect it is not a problem there.

    When you go to the Amazon Link Settings page and view the Templates or the Default Templates – do the previews of these work as you expect? Also the ‘Template Help’ box on the Options page should have a list of all the keywords is this shown okay?



    I looked into the amazonSearch.php again.

    I assume something is not working with the regex / php_replace_callback… In the callback function these lines:

    $keyword  = strtolower($args['keyword']);
    $keywords = $this->alink->get_keywords();
    $settings = $this->settings;

    $keyword doesn’t contain anything because the key ‘keyword’ doesn’t exist (I tried to echo $args[‘keyword’]). If I make a print_r on $args I get an array like this:

    Array ( [0] => %TAG% [1] => TAG ) Array ( [0] => %ASINS% [1] => ASINS ) Array ( [0] => %TEXT% [1] => TEXT ) Array ( [0] => %MPLACE% [1] => MPLACE ) Array ( [0] => %TLD% [1] => TLD ) Array ( [0] => %MPLACE% [1] => MPLACE )

    Template previews are also wrong:

    Template help shows up ok:


    Plugin Author paulstuttard


    Looks like the regex isn’t using the named sub pattern correctly, which is odd because that was supposed to work from PHP 5.2.2 onwards (Sub-patterns).

    Try changing the regex from:




    note the second regex should read:


    This is what I should have been using in the first place, must have misread the manual!

    This change doesn’t affect my version, so hope it helps with yours!



    thank’s for your ideas and help. I tried the changes in the regex, but unfortunately they didn’t help, too. It was still not working with the changes.

    I was trying to inspect this issue for so long, but couldn’t get it to work. Because I was thinking the problem lies in the PHP version / server configuration I checked if I could switch to another PHP version.

    I was lucky, via htaccess I could switch now from PHP Version 5.2.6-1+lenny16 to PHP Version 5.3.6 – and now I am glad – it works!!!

    So whenenver you come across this weird problem again, I think it is some kind of bug in this special php version…

    Thank’s for your time!

    Plugin Author paulstuttard



    I’m glad you sorted it out in the end, I’ve been holding off releasing this version of the plugin because of swapping to the new regex approach. Might be a problem if it affects lots of people.

    Thanks for persevering and letting me know how you resolved it,



Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Template keywords aren't replaced’ is closed to new replies.