Created
January 3, 2016 20:49
-
-
Save joshuadavidnelson/18918faa099ea5f20aba to your computer and use it in GitHub Desktop.
Basic Transient function
This file contains 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 | |
/** | |
* Featured projects. | |
* | |
* @since 1.0.0 | |
* | |
* @return void | |
*/ | |
function child_home_projects() { | |
// The pre-compiled output is empty | |
$output = ''; | |
// Grab the tranisent | |
$projects = get_transient( 'home_projects' ); | |
if( false === $projects || ( defined( 'DISABLE_TRANSIENTS' ) && true == DISABLE_TRANSIENTS ) ) { | |
$projects = ''; | |
// do the stuff | |
// if we have output, save it | |
if( !empty( $projects ) ) | |
set_transient( 'home_projects', $projects, 10 ); // change 10 to seconds transient is stored | |
} | |
// add another wrap or alter the output | |
if( !empty( $projects ) ) | |
$output = $projects; | |
// Print the output | |
if( !empty( $output ) ) | |
echo '<div class="row" id="projects">' . $output . '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment