Shortcode not working
-
Hi Otto,
The plugin works great but I’m having an issue with getting shortcode to be processed properly in the widget. Here is what I did:
1. Added filters to my active theme function.php file
// Allow shortcodes in text widgets add_filter('widget_text', 'shortcode_unautop'); add_filter('widget_text', 'do_shortcode'); // Allow shortcodes in php code widget add_filter('widget_execphp', 'shortcode_unautop'); add_filter('widget_execphp', 'do_shortcode');
2. Added the following to the php widget
<?php $id = get_the_ID(); $amazon_product_asin_value = get_post_meta($id, 'amazon_product_asin', true); echo do_shortcode('<div> [amazon asin=' . $amazon_product_asin_value . '&template=buynowamazon_widget&chan=default] </div>'); ?>
I also tried without do_shortcode and same result.
#2 properly outputs the shortcode of [amazon asin=B008I20FT8&template=buynowamazon_widget&chan=default] which works fine if I just enter this in the standard text widget
I’m using the Amazon Link plugin which generates the shortcodes
Any idea?
Thanks again.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Shortcode not working’ is closed to new replies.