Last active
August 29, 2015 14:05
-
-
Save halgatewood/6bbe625d2e8c6b78aa50 to your computer and use it in GitHub Desktop.
How to programmatically get the Yahoo WOEID when using the Awesome Weather Widget Pro WordPress Plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $woeid = false; | |
| $location = "Madrid"; // SET THIS TO YOUR SEARCH CITY | |
| $awe_location_cache_name = "awe_location_cache_" . $location; | |
| if( get_transient( $awe_location_cache_name ) ) | |
| { | |
| $woeid = get_transient( $awe_location_cache_name ); | |
| } | |
| else | |
| { | |
| $check_yahoo = awe_ping_yahoo_first_results( $location ); | |
| if( $check_yahoo AND $check_yahoo->woeid ) | |
| { | |
| $woeid = $check_yahoo->woeid; | |
| set_transient( $awe_location_cache_name, $woeid, 15552000 ); // CACHE FOR LONG TIME | |
| } | |
| } | |
| // EXAMPLE USAGE | |
| echo awesome_weather_shortcode ( array( 'location' => $location, 'woeid' => $woeid, 'units' => 'C' ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment