• Hi,

    I’d like to say first off that this for me has been the best plugin for amazon i’ve ever seen! So thank you!!

    I hope this is possible as I’ve tried to do this myself and failed.

    I want to add the product ASIN number into a custom meta field called “AmazonAsin”

    I then want add that into the shortcode below.

    if (function_exists('amazon_shortcode')) echo amazon_shortcode("asin=B006J73UUA&template=Template");

    For Example

    if (function_exists('amazon_shortcode')) echo amazon_shortcode("asin= ''. echo get_post_meta($postid, 'AmazonAsin', true); . '' &template=Template");
    

    Thanks again for the plugin and I look forward to hearing from you!

    J

    • This topic was modified 5 years, 5 months ago by MrWilson2013.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter MrWilson2013

    (@mrwilson2013)

    I thought I better include what I’ve tried

    When “AmazonAsin” contains [amazon template=template&asin=B00ADMY592]

    <?php
    $shortcode = get_post_meta($post->ID,'AmazonAsin',true);
    echo do_shortcode($shortcode); 
    ?>
    <?php if (function_exists('amazon_shortcode')) echo amazon_shortcode(get_post_meta($post->ID, 'AmazonAsin', true)); ?>
    

    When “AmazonAsin” contains just the ASIN number of a product

    <?php 
    $AmazonAsin = get_post_meta($post->ID, 'AmazonAsin', TRUE);
    
    if (function_exists('amazon_shortcode')) echo amazon_shortcode('asin='.$AmazonAsin.'&template=Template');										
    
    ?>

    This almost worked. It displayed the template but did not call the price or link

    • This reply was modified 5 years, 5 months ago by MrWilson2013.
    Plugin Author paulstuttard

    (@paulstuttard)

    Hi,

    The first one did not work as the content of “AmazonAsin” should have just been the arguments e.g.:

    template=template&asin=B00ADMY592

    Which is what the second version used, not sure why it did not render correctly, but have to admit I have not tested that particular part of the plugin in a while.

    If you put that shortcode into the body of a post, does it work?

    [amazon template=template&asin=B00ADMY592]

    Ideally on the same page, try and render your dynamically created one. If you have the Amazon Link cache enabled that would rule out any AWS access problems.

    Paul

    Thread Starter MrWilson2013

    (@mrwilson2013)

    From the man himself. Thanks for the reply!

    I’ve tried a few different ways including removing the “[ ]” from the shortcode contained within the ACF field.

    When using:

    global $wp_query; $postid = $wp_query->post->ID;
    $shortcode = get_post_meta($postid,'AmazonAsin',true);
    echo do_shortcode($shortcode); 
    wp_reset_query();

    When AmazonAsin contains

    amazon template=template&asin=B00ADMY592

    It displays only whats contained and doesnt actually run the shortcode.

    Thanks for the help.

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