shortcode in widget area not working
-
I’m using the wordpress php widget but I am unable to process WordPress shortcode – the php just renders the shortcode instead of processing it. HEre is what I did
Added filters to my active theme function.php file
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');
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
Any ideas?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘shortcode in widget area not working’ is closed to new replies.