Last active
August 29, 2015 14:00
-
-
Save carmichaelize/11078011 to your computer and use it in GitHub Desktop.
Wordpress Transients & API Calls
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
<?php | |
//Get transient data | |
$data = get_transient( 'data_key' ); | |
//Check transient data exists | |
if(!$data){ | |
//Query API | |
//Handle API Response | |
//Cache Response | |
if($data){ | |
set_transient( 'data_key', $data, 60*60 ); | |
} | |
} | |
//Render data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment