What if you could use the weather to help decide better ways of informing your customers?
Supper Road Website - Laptop View

Margaret River Attractions

For a tourist attraction weather can make or break the day. A website packed with bright sunny images of tourists out enjoying the sunshine is a great sell when the weather outside matches, but what if it's absolutely bucketing down outside?

Tasked with helping the Margaret River Busselton Tourism Association produce a new website for their lighthouse & cave attractions we decided to use the weather to our advantage.

Website Development by Nathan Shanahan, Designed by Brett Layton at TwoFromTwo


Using Open Weather Map to determine which version of a website to show.

As well as installing a switch to allow temporary disabling and override of weather detection I also added functionality for checking the weather only once every thirty minutes.

As we are also displaying weather conditions at each lighthouse this example draws the weather conditions from each location and updates the database accordingly.

// Define locations and location ID 
 $locations = array(
  "margaret_river" => "2066981", 
  "cape_naturaliste" => "2078304",
  "cape_leeuwin" => "2077476",

 /* ===============================================
 For each location retrieve information from
 and update ACF custom fields with weather and 
 temperature data.   
 =============================================== */
 foreach ($locations as $location => $locationId) {
     // Retrieve current conditions 
     $currentConditions = $data['weather'][0]['description'];
     // Define ACF field name $location + _weather. EG. margaret_river_weather
     $weatherField = $location.'_weather';
     // Update the ACF option field
     update_field( $weatherField, $currentConditions, 'option' );
     // Retrieve temperature  
     $currentTemp = $data['main']['temp'];
     // Define ACF field name $location + _temp. EG. margaret_river_temp
     $tempField = $location.'_temp';
     // Update the ACF option field
     update_field( $tempField, $currentTemp, 'option' );

We have now stored the weather condition and temperatures in ACF custom fields. Now that is done the next step is to match current weather conditions against the those selected in the ‘Conditions to Match’ options we’ve added to the WordPress Admin panel.

 /* ===============================================
 Test if current conditions in Margaret River
 match the conditions selected in 'conditions 
 to match'. Update weather version accordingly. 
 =============================================== */
 // Check against the conditions in Margaret River 
 $currentConditions = get_field('margaret_river_weather', 'option');
 if(in_array($currentConditions, get_field('conditions_to_match', 'option'), true )) {
   update_field( 'weather_version', 'alt_weather', 'option' ); 
 } else {
   update_field( 'weather_version', 'normal', 'option' );
Visit Margaret River Attractions