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, 7 months ago by
MrWilson2013.
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
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.