Skip to content

Instantly share code, notes, and snippets.

@carolinerusso
carolinerusso / flag-recent-post-by-time-ago.php
Last active December 8, 2015 14:24
Show "new" label for WordPress posts published within the last 24 hours (86400 seconds)
<?php
$date = strtotime ( get_the_time('Y-m-d g:i:s') );
$blogtime = strtotime ( current_time( 'mysql' ) );
if( $blogtime - $date <= 86400 ) :
echo '<span class="label label-new">New!</span>';
endif;
?>
@carolinerusso
carolinerusso / instagram.php
Created December 7, 2015 15:38
Connect to and return Instagram uploads via Instagram API/PHP/cURL
<?php
function get_instagram_data( $url ) {
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 20 );
$result = curl_exec( $ch );
curl_close( $ch );
return $result;
}
@carolinerusso
carolinerusso / gist:5041e981e249ec2f588a
Created March 5, 2015 14:17
Linking user_meta to taxonomy (and pulling user_meta data)
<?php
$queried_object = get_queried_object();
$term_name = $queried_object->name;
$users = get_users( array( 'meta_key' => 'school_name', 'meta_value' => $term_name, ) );
// users have user_meta stored that matches (exactly) the "school" and "sorority" taxonomies
// so let's get all users based on their CURRENT taxonomy association
// meaning, that if we are on taxonomy "School" > term "Harvard University"
// we'll get all users that have meta_key "school_name" AND meta_value "Harvard University"
@carolinerusso
carolinerusso / SassMeister-input-HTML.html
Last active August 29, 2015 14:16
Generated by SassMeister.com.
<div id="wrap">
<div id="content"></div>
<div id="sidebar"></div>
</div>