Shortcode with variables for location values not working
-
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.
The topic ‘Shortcode with variables for location values not working’ is closed to new replies.