Amazon Link
[resolved] shortcode in widget area not working (3 posts)

  1. jncnath
    Posted 3 years ago #

    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

    $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?


  2. paulstuttard
    Plugin Author

    Posted 3 years ago #


    The plugin doesn't use the WordPress shortcode processing so that won't work. Try using something like:

    echo '<div>' . amazon_shortcode("asin=$amazon_product_asin_value&template=buynowamazon_widget&chan=default") . '</div>';


  3. jncnath
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Amazon Link
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic