• I am using WP Wunderground, WP Geolocation JS and PHP Shortcode.

    I am attaching the city and state of the visitor to variables like so:

    $weathercity = do_shortcode('[mmjs-city]');
    $weatherstate = do_shortcode('[mmjs-regionname]');

    I can echo those locations within a page or post using the PHP Shortcode plugin like so:

    [php]
    $weathercity = do_shortcode('[mmjs-city]');
    $weatherstate = do_shortcode('[mmjs-regionname]');
    echo $weathercity .', '.$weatherstate;
    [/php]

    Which essentially renders something like Chicago, Illinois.

    I can echo a shortcode using the PHP Shortcode plugin like so:

    [php]
    $weathercity = do_shortcode('[mmjs-city]');
    $weatherstate = do_shortcode('[mmjs-regionname]');
    echo $weathercity .', '.$weatherstate;
    echo '[forecast location='.$weathercity.', '.$weatherstate.']';
    [/php]

    It will actually spit out the shortcode as :

    [forecast location="Chicago, Illinois"]

    However, if I try to run do_shortcode on the last line like so:

    [php]
    $weathercity = do_shortcode('[mmjs-city]');
    $weatherstate = do_shortcode('[mmjs-regionname]');
    echo $weathercity .', '.$weatherstate;
    echo do_shortcode('[forecast location='.$weathercity.', '.$weatherstate.']');
    [/php]

    The weather does not show up at all. Any ideas on how I can handle this? I really just want to be able to sniff the location of the user and display weather for that location.

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • looking for same input

    P T

    (@pthomson87)

    This works for me… have a fiddle, good luck

    <div class="weather">' . do_shortcode("[forecast location='$coordinated' caption=\"6-Day Weather forecast for <b>$ev_location</b> ($coordinated):\" measurement=\'C\' todaylabel=\"Today\" datelabel=\"%%weekday%% <br> date(\'d M \'n\')\" highlow=\'%%high%%&deg;/%%low%%&deg;\' numdays=\"6\" cache=\"True\" iconset=\"Generic\" class=\"weather_table\"]") . '</div>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode with variables for location values not working’ is closed to new replies.