WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. jncnath
    Member
    Posted 1 year 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

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

    http://wordpress.org/extend/plugins/amazon-link/

  2. paulstuttard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    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>';

    Paul

  3. jncnath
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic