• I am trying to use custom fields to pull through the location from a post/page and use as a widget in the sidebar

    I have found the following thread where someone has got it working but the code doesnt appear to work for me:

    <?php echo do_shortcode('[forecast location="' . $city . ' , ' . $state . '" caption="' . $city . ' , ' . $state . '" numdays="3" iconset="Cartoon" class="css_table_class" cache="true"]'); ?>

    This is what I have and it works:

    <?php
    $city = get_the_title();
    $country = UK;
    echo do_shortcode ('[forecast location= "London, ' . $country . '" caption=" ' . $city. ', ' . $country . '" numdays="2" iconset="Cartoon" class="css_table_class" cache="true"]'
    );
    ?>

    HOWEVER, as soon as I try to pull in the $city and replace the above code for the forecast location= with

    "' . $city . ', ' . $country . '" it stops working

    Anyone have any ideas please?

    https://www.ads-software.com/extend/plugins/wunderground/

  • The topic ‘PHP Widget and do_shortcode’ is closed to new replies.