I am setting up custom fields in WordPress in order to be able to enter an ASIN number from amazon and have it pass through the shortcode I have in the template file.
In my custom field I am using Name:asin and Value:(whatever ASIN # I want to put in)
Here is what I have currently in the template file:
<?php $asin = get_post_meta( $post->ID, 'asin', true); ?>
<?php echo $asin ?>
<?php echo do_shortcode( '[scrapeazon asin="B002P4SMHM" width="650" height="400" border="false" country="us")]' );?>
I am trying to put the variable $asin into the scrapeazon shortcode that I have, something like this:
<?php echo do_shortcode( '[scrapeazon asin="<?php echo $asin ?" width="650" height="400" border="false" country="us")]' );?>
But this is not working, any ideas?
What about this approach?
So don ‘t try to get the custom value in the template. Just deal with it in the shortcode function. Through the global declared $post variable it should work. Yes, global ist not very clean. But it ‘s wordpress …