Skip to content

Instantly share code, notes, and snippets.

View miklb's full-sized avatar
🎣
Gone Fishing

Michael Bishop miklb

🎣
Gone Fishing
View GitHub Profile
@miklb
miklb / gist:1343077
Created November 6, 2011 16:03
sample of extending action_init_theme(); in child Habari theme
public function action_init_theme() {
parent::action_init_theme();
Format::apply( 'format_date', 'post_pubdate_out', '<span class="post-day">{j}</span><span class="post-month">{F}</span>');
}
@miklb
miklb / gist:2050780
Created March 16, 2012 16:12
dynamic sidebar for home page
function kkf_home_sidebar() {
if ( is_home()) {
remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
add_action( 'genesis_after_content', 'kkf_get_home_sidebar' );
}
}
function kkf_get_home_sidebar() {
get_sidebar( 'news' );
}
@miklb
miklb / gist:2205266
Created March 26, 2012 14:00
grab all image attachments minus post_thumbnail in WordPress
function kkf_get_images($overrides = '', $exclude_thumbnail = false)
{
return get_posts(wp_parse_args($overrides, array(
'numberposts' => -1,
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'exclude' => $exclude_thumbnail ? array(get_post_thumbnail_id()) : array(),
'orderby' => 'menu_order ID'
@miklb
miklb / gist:2205762
Created March 26, 2012 15:12
loop through images
remove_action( 'genesis_post_content' , 'genesis_do_post_content' );
add_action( 'genesis_post_content' , 'kkf_do_custom_post_content' );
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
function kkf_do_custom_post_content() { ?>
<?php $photos = kkf_get_images('posts_per_page=12', true); ?>
<?php if ( $photos ) { ?>
<ul class="newsletter-gallery">
<?php foreach ($photos as $photo) {
@miklb
miklb / gist:2252101
Created March 30, 2012 14:57 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@miklb
miklb / functions.php
Created April 5, 2012 15:16
Add Pdf and Word Doc filtering to WordPress Media Library
/**
* add custom "mime types" (file supertypes)
* @param array $post_mime_types
* @return array
*/
function filterPostMimeTypes($post_mime_types) {
$post_mime_types['application/pdf'] = array('PDF', 'Manage PDFs', _n_noop('PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>'));
$post_mime_types['application/msword'] = array('Word Docs', 'Manage Word Docs', _n_noop('Word DOC <span class="count">(%s)</span>', 'Word Docs <span class="count">(%s)</span>'));
return $post_mime_types;
}
@miklb
miklb / search form
Created April 21, 2012 03:31
Auto Suggest WordPress hacking stuff
add_action('wp_head', 'kkf_add_autosuggest');
function kkf_add_autosuggest() {
?>
<script type="text/javascript">
// Function to add tag auto suggest
function setSuggest(id) {
jQuery('#' + id).suggest("<?php echo admin_url('/admin-ajax.php?action=ajax-tag-search&tax=search_term'); ?>", { delay: 500, minchars: 2 });
}
</script>
@miklb
miklb / gist:2437076
Created April 21, 2012 13:28
WordPress redirect single search result
/*If only one search result match, redirect to that page */
function kkf_singlesearch_redirect() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
}
}
}
@miklb
miklb / gist:2560749
Created April 30, 2012 18:21
Modify WordPress excerpt to create read more link
// change excerpt ellipse to link to full post
function excerpt_ellipse($text) {
return str_replace('[...]', ' … <a href="'.get_permalink().'">Continue reading ' .get_the_title(). '</a>', $text);
return strip_tags($text, '<p>');
}
add_filter('excerpt_more', 'excerpt_ellipse');
@miklb
miklb / dabblet.css
Created May 18, 2012 18:36 — forked from anonymous/dabblet.css
Proof of Concept for "fancy" call to action
/**
* Proof of Concept for "fancy" call to action
*/
body {background: #fff;}
@-webkit-keyframes rotate {
0% { -webkit-transform: rotate(0deg) }
100% { -webkit-transform: rotate(360deg) }}