Skip to content

Instantly share code, notes, and snippets.

View jeremyfelt's full-sized avatar
🍕
Look at that pizza emoji!

Jeremy Felt jeremyfelt

🍕
Look at that pizza emoji!
View GitHub Profile
@jeremyfelt
jeremyfelt / gist:2625350
Created May 7, 2012 01:37
Post type argument test results
'rewrite' => true
'public' => true 'publicly_queryable' => true /cpt-slug/cpt-post-slug Loads fine
'public' => false 'publicly_queryable' => true /cpt-slug/cpt-post-slug Loads fine
'public' => true 'publicly_queryable' => false /cpt-slug/cpt-post-slug 404 Error
'public' => false 'publicly_queryable' => true /cpt-slug-cpt-post-slug 404 Error
'rewrite' => false
'public' => true 'publicly_queryable' => true /?cpt-slug=cpt-post-slug Loads fine
'public' => true 'publicly_queryable' => true /?p=ID&post_type=cpt-slug Loads fine
'public' => false 'publicly_queryable' => true /?cpt-slug=cpt-post-slug Loads fine
@jeremyfelt
jeremyfelt / gist:2669822
Created May 13, 2012 00:18
Filters enabled in Youtube Favorite Video Posts
<?php
/* A brief overview of filters that are now available in Youtube Favorite Video Posts.
*
* These allow easy overriding of the default post title and content before the
* new post is created.
*/
add_filter( 'yfvp_new_video_embed_code', 'myprefix_change_yfvp_post_content', 10, 1 );
/* Adds a little nonsense introduction to the video before embedding the
* iframe that was provided by default */
@jeremyfelt
jeremyfelt / gist:2776277
Created May 23, 2012 16:41
ACM Filter examples
<?php
add_filter( 'acm_register_provider_slug', 'unisport_register_acm_provider_slug' );
function unisport_register_acm_provider_slug( $current_providers ) {
$current_providers->unisport_doubleclick = array(
'provider' => 'Unisport_Doubleclick_ACM_Provider',
'table' => 'Unisport_Doubleclick_ACM_WP_List_Table' );
return $current_providers;
}
@jeremyfelt
jeremyfelt / gist:2839691
Created May 31, 2012 00:04
pre_get_posts over query_posts
<?php
add_action( 'pre_get_posts', 'my_alter_home_posts' );
function my_alter_home_posts( $query ) {
if ( $query->is_home() && $query->is_main_query() )
$query->set( 'posts_per_page', 3 );
}
@jeremyfelt
jeremyfelt / gist:3006286
Created June 27, 2012 19:35
Rsync repo to repo
repo_to_repo() {
local DEVENV="/directory/to/where/both/repos/are/stored/"
rsync -rv --delete --exclude='.svn' $DEVENV$1/* $DEVENV$2
cd $DEVENV$2
svn status | grep '^!' | awk '{print $2}' | xargs svn rm
svn status | grep '^?' | awk '{print $2}' | xargs svn add
}
@jeremyfelt
jeremyfelt / gist:3050095
Created July 4, 2012 23:36
Related posts are related
<?php
$category_ids = wp_get_object_terms( get_the_ID(), 'category', array( 'fields' => 'ids' ) );
$post_tag_ids = wp_get_object_terms( get_the_ID(), 'post_tag', array( 'fields' => 'ids' ) );
$related_query = new WP_Query( array(
'posts_per_page' => 3,
'post__not_in' => array( get_the_ID() ),
'orderby' => 'rand',
'no_found_rows' => true,
@jeremyfelt
jeremyfelt / gist:3094244
Created July 11, 2012 22:42
Local YUI JS Lint Check
js_lint_check() {
local DEVENV=$PWD
local YUICOM="/path/to/yuicompressor/jar/"
cd $YUICOM
java -jar yuicompressor-2.4.7.jar -v $DEVENV/$1 -o $DEVENV/$2
cd $DEVENV
}
@jeremyfelt
jeremyfelt / gist:3430653
Created August 22, 2012 23:50
Add a default 'current-menu-item' class
add_filter( 'wp_nav_menu_objects', 'edit_nav_main_objects', 10, 2 );
/**
* Parse nav menu items and add a current-menu-item class to the first menu item
* in in the menu if no current-menu-item currently exists.
*
* @param $current_menu_items array of objects containing menu items
* @param $current_menu object containing menu information
*
* @return mixed array of objects containing menu items
*/
@jeremyfelt
jeremyfelt / google-dfp-acm-config.php
Created August 23, 2012 21:23
Google DFP JS Explanation
<?php
/**
* Basic configuration for multiple DFP JS ad tags in Ad Code Manager
*
* Our ad units are named 'test_ad_300x250' and 'test_ad_728x90'
* Our DFP ID is 12345678
* Our ad slot IDs will be automatically created
*
*/
@jeremyfelt
jeremyfelt / gist:3638823
Created September 5, 2012 15:50
WP Feed Cache Transient Sample
<?php
function my_function_that_grabs_the_feed() {
add_filter( 'wp_feed_cache_transient_lifetime', 'modify_feed_cache' );
$my_feed = fetch_feed( esc_url( $feed_url ) );
remove_filter( 'wp_feed_cache_transient_lifetime', 'modify_feed_cache' );
}