Skip to content

Instantly share code, notes, and snippets.

@halgatewood
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save halgatewood/6bbe625d2e8c6b78aa50 to your computer and use it in GitHub Desktop.

Select an option

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.
$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