Skip to content

Instantly share code, notes, and snippets.

View stellarcowboy's full-sized avatar

Kenneth White stellarcowboy

View GitHub Profile
@stellarcowboy
stellarcowboy / gist:2910459
Created June 11, 2012 14:53
Add Custom Post Type And Taxonomy Summary Count To Dashboard - WordPress
// Add all custom post types to the "Right Now" box on the Dashboard
add_action( 'right_now_content_table_end' , 'ucc_right_now_content_table_end' );
function ucc_right_now_content_table_end() {
$args = array(
'public' => true ,
'_builtin' => false
);
$output = 'object';
$operator = 'and';
@stellarcowboy
stellarcowboy / gist:2910452
Created June 11, 2012 14:52
Display The Name Of The Custom Taxonomy For The Current Post - WordPress
$value = get_query_var($wp_query->query_vars['taxonomy']);
echo get_term_by('slug',$value,$wp_query->query_vars['taxonomy']);
@stellarcowboy
stellarcowboy / gist:2363077
Created April 11, 2012 22:06
WordPress Image Attachment Toolbox
function get_string_between($string, $start, $end){ //required for parsing attachment URL's in attachment_image_retrieve
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
function attachment_image_retrieve($size = 'thumbnail', $limit = '-1') {
@stellarcowboy
stellarcowboy / Facebook Conditional Load
Created February 11, 2012 16:59
Conditionally load Facebook social plugin based on screen width
<div id="fb-catcher"></div>
<script>
if (document.documentElement.clientWidth >= 600) {
document.getElementById('fb-catcher').innerHTML='<div id="fb-root"></div>';
}
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;