Skip to content

Instantly share code, notes, and snippets.

@micahwave
micahwave / gist:3240092
Created August 2, 2012 19:53
tax query
$latest_galleries = wp_cache_get( 'latest_galleries', 'time_gallery_cache' );
if( !$latest_galleries ) {
$latest_galleries = get_posts( array(
'posts_per_page' => 6,
'post_status' => 'publish',
'tax_query' => array( array(
'taxonomy' => 'time_post_format',
'field' => 'slug',
document.write('<!-- Template Id = 12195 Template Name = TIM - High Impact 1x1 - 468x648 -->\n');
highAdLayout('468','648');
document.write('\n\n');
adid="260411135";
document.write('');
document.write('<!-- New High Impact Trigger -->\n');
window.responsiveAd.highImpact( "sidebar", 468, 648 );
@micahwave
micahwave / gist:3317698
Created August 10, 2012 20:44
guest author madness
/**
* Returns an array of contributors and stories based on passed tab.
*
*/
function time_get_contributors( $tab = 'all' ) {
global $wpdb, $wp_query;
$contributors = wp_cache_get( 'time_contributors_'.$tab, 'time_contributors_cache' );
@micahwave
micahwave / gist:3364024
Created August 15, 2012 21:52
guest author latest post
/**
* Add the most recent post id to each guest author as meta
*/
function time_guest_author_latest_post( $post_id, $post ) {
if( $post->post_type == 'post' ) {
$guest_id = get_post_meta( $post_id, 'time_guest_author', true );
if( $guest_id ) {
@micahwave
micahwave / gist:3928578
Created October 21, 2012 21:30
rewrite rules
/**
* Custom endpoints, rewrite rules for contributors page tabs
*/
function time_rewrite_rules() {
global $wp_rewrite;
add_rewrite_tag( '%photo%', '([^&]+)' );
add_rewrite_tag( '%slide%', '([^&]+)' );
add_rewrite_tag( '%tab%', '([^&]+)' );
@micahwave
micahwave / gist:4018279
Created November 5, 2012 16:53
publish package slides
/**
* Make slide post_status mirror the post status of the parent post
*
* Using $wpdb to update the values because I don't want to toggle all our other actions
*/
function time_transition_package_status( $new_status, $old_status, $post ) {
global $wpdb;
// this is only for posts
<!--[if lt IE 9]>
<link rel="stylesheet" href="http://entertainment.time.com/wp-content/themes/vip/time2012/library/assets/css/style.css" media="all"/>
<script src="http://entertainment.time.com/wp-content/themes/vip/time2012/library/assets/js/libs/respond/respond.min.js"></script>
<![endif]-->
<!--[if gt IE 8]><!--><link rel="stylesheet" href="http://s0.wp.com/wp-content/themes/vip/time2012/library/assets/css/style.css?m=1363875156g" media="all"/><!--<![endif]-->
@micahwave
micahwave / gist:5302094
Created April 3, 2013 15:14
How NOT to do responsive
@media screen and (max-width: 1122px) {
.full-col {
width: 1081px;
}
}
@media screen and (max-width: 1115px) {
.full-col {
width: 1084px;
}
<?php
// somewhere in single.php
if( time_is_paid_content() ) {
if( time_is_paid_user() ) {
the_content();
} else {
echo 'Sorry, you must log in or sign up to view this content.'
}