Title: Metadata Shortcode
Last modified: June 22, 2019

---

# Metadata Shortcode

 *  [MrWilson2013](https://wordpress.org/support/users/mrwilson2013/)
 * (@mrwilson2013)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/metadata-shortcode/)
 * 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 6 years, 11 months ago by [MrWilson2013](https://wordpress.org/support/users/mrwilson2013/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [MrWilson2013](https://wordpress.org/support/users/mrwilson2013/)
 * (@mrwilson2013)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/metadata-shortcode/#post-11663606)
 * 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 6 years, 11 months ago by [MrWilson2013](https://wordpress.org/support/users/mrwilson2013/).
 *  Plugin Author [paulstuttard](https://wordpress.org/support/users/paulstuttard/)
 * (@paulstuttard)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/metadata-shortcode/#post-11665023)
 * 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](https://wordpress.org/support/users/mrwilson2013/)
 * (@mrwilson2013)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/metadata-shortcode/#post-11665325)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/amazon-link_070606.svg)
 * [Amazon Link](https://wordpress.org/plugins/amazon-link/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amazon-link/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amazon-link/)
 * [Active Topics](https://wordpress.org/support/plugin/amazon-link/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amazon-link/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amazon-link/reviews/)

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)

 * 3 replies
 * 2 participants
 * Last reply from: [MrWilson2013](https://wordpress.org/support/users/mrwilson2013/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/metadata-shortcode/#post-11665325)
 * Status: not resolved