• Resolved Pete

    (@angio)


    I’m using PHP Widget which allows PHP code to execute from a widget. I tried using this code to execute do_shortcode but it’s not rendering

    <?php
    $lat = get_field('woo_maps_lat');
    $long = get_field('woo_maps_long');
    echo do_shortcode('[forecast location="' . $lat .','.$long. '" measurement=\'C\']');

    ?>
    If I echo a variable with simply `echo $lat;’ it works. So the PHP Widget is working fine. The problem is echoing the shortcode in the widget. I can add shortcoded just fine to a widget but I need to be able to add the php variables where they are.

    I tried adding add_filter('widget_text', 'do_shortcode'); to my functions.php but it’s still not rendering properly. Any suggestions?

    Thanks

    http://wordpress.org/extend/plugins/wunderground/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Zack Katz

    (@katzwebdesign)

    Sorry, it looks good to me. Not sure what the problem might be.

    Thread Starter Pete

    (@angio)

    Is there an pure PHP function I can use other than the shortcode [forcast]

    Thread Starter Pete

    (@angio)

    I resolved this by removing all quotes from the do_shortcode code and the working code is below

    <div>
    <?php
    $lat = get_field('woo_maps_lat');
    $long = get_field('woo_maps_long');
    echo do_shortcode('[forecast location=' . $lat .','.$long. ']');
    ?>
    </div>
    Plugin Author Zack Katz

    (@katzwebdesign)

    Great, glad that worked. Thanks for posting the solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Weather Forecast – WP Wunderground] PHP Widget and do_shortcode?’ is closed to new replies.