Skip to content

Instantly share code, notes, and snippets.

View heyawhite's full-sized avatar

Alexandra White heyawhite

View GitHub Profile
@heyawhite
heyawhite / gist:1aa752722956eb72ea9d
Last active August 29, 2015 14:20
WP Transients - Get Transient Data
// Get any existing copy of our transient data
if ( false === ( $special_query_results = get_transient( 'special_query_results' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$special_query_results = new WP_Query( 'cat=5&order=random&tag=tech&post_meta_key=thumbnail' );
set_transient( 'special_query_results', $special_query_results, 12 * HOUR_IN_SECONDS );
}
// Use the data like you would have normally...
@heyawhite
heyawhite / gist:3faf6f62fa8319e411e6
Created May 6, 2015 18:24
Chartbeat Datagather
if ( false === ( $sidebar_popular_chartbeat = get_transient( 'sidebar_popular_chartbeat' ) ) ) {
$sidebar_popular_chartbeat = wp_remote_get("http://api.chartbeat.com/live/toppages/v3/?apikey=XXXXX&host=yourwebsite.com");
set_transient( 'sidebar_popular_chartbeat', $sidebar_popular_chartbeat, 600 );
}
@heyawhite
heyawhite / gist:a6fcb0198e462946b004
Last active August 29, 2015 14:20
WP Transients - Chartbeat
$sidebar_popular_chartbeat = wnet_get_transient_remote_json('sidebar_popular_chartbeat', 'http://api.chartbeat.com/live/toppages/v3/?apikey=XXXXX&host=yourwebsite.com', 600);