Skip to content

Instantly share code, notes, and snippets.

View GaryJones's full-sized avatar

Gary Jones GaryJones

View GitHub Profile
@GaryJones
GaryJones / gist:1258784
Created October 3, 2011 09:37 — forked from jaredatch/gist:1256954
Using the template_include filter in WordPress
<?php
add_filter( 'template_include', 'ja_template_include' );
/**
* Apply a template to all subcategories of a certain parent category.
*
* @author Jared Atchison
* @link http://www.jaredatchison.com/2011/10/02/taking-advantage-of-the-template_include-filter/
*
* @param string $template Existing path to template file
* @return string Potentially amended path to template file
@GaryJones
GaryJones / gist:1301089
Created October 20, 2011 13:05 — forked from jaredatch/gist:1300302
Exclude category from search results in WordPress
<?php
add_filter( 'pre_get_posts', 'ja_search_filter' );
/**
* Exclude category 7 from search results.
*
* @since ?.?.?
* @author Jared Atchison
* @link https://gist.github.com/1300302
*
@GaryJones
GaryJones / gist:1547745
Created January 1, 2012 16:45 — forked from billerickson/gist:1547518
Increase post count to 20 - Right Way
<?php
add_action( 'pre_get_posts', 'be_increase_posts_on_quotes_archive' );
/**
* Increase posts on quotes archive.
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
*
@GaryJones
GaryJones / gist:1547753
Created January 1, 2012 16:48 — forked from billerickson/gist:1547637
Create session metaboxes
<?php
add_action( 'init', 'be_initialize_meta_boxes' );
/**
* Initialize the metabox code library.
*
* Since this code might be in the theme and multiple plugins,
* see if it exists already before initializing it.
*
*/
@GaryJones
GaryJones / gist:1612938
Created January 14, 2012 21:20 — forked from billerickson/gist:1612826
Sort specific category to display alphabetically.
<?php
add_action( 'pre_get_posts', 'be_sort_articles_category' );
/**
* Sort 'articles' category by name
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
* @param object $query data
*
@GaryJones
GaryJones / functions.php
Created February 10, 2012 12:03 — forked from billerickson/functions.php
Genesis Grid Loop - Parts 1-3
<?php
/**
* Possibly amend the loop.
*
* Specify the conditions under which the grid loop should be used.
*
* @author Bill Erickson
* @author Gary Jones
* @link http://code.garyjones.co.uk/genesis-grid-loop-advanced/
@GaryJones
GaryJones / functions.php
Created February 11, 2012 12:20 — forked from billerickson/widget nav.php
Add widget area before primary menu items in Genesis.
<?php
add_filter( 'genesis_nav_items', 'sws_social_icons', 10, 2 );
add_filter( 'wp_nav_menu_items', 'sws_social_icons', 10, 2 );
/**
* Adds a widget area before primary menu items.
*
* @author Bill Erickson
* @author Gary Jones
* @link https://gist.github.com/gists/1799174
@GaryJones
GaryJones / functions.php
Created February 12, 2012 04:01 — forked from billerickson/functions.php
Genesis Grid Loop Advanced
<?php
/**
* Possibly amend the loop.
*
* Specify the conditions under which the grid loop should be used.
*
* @author Bill Erickson
* @author Gary Jones
* @link http://code.garyjones.co.uk/genesis-grid-loop-advanced/
@GaryJones
GaryJones / front.php
Created February 16, 2012 17:17
Live Toolbar
<?php
/**
* Create the Live Toolbar.
*
* @since 1.0.0
*/
function radio_live_toolbar() {
@GaryJones
GaryJones / gist:2437195
Created April 21, 2012 13:55 — forked from miklb/gist:2437076
WordPress redirect single search result
<?php
add_action( 'template_redirect', 'kkf_single_search_redirect' );
/**
* If only one search result match, automatically redirect to that result.
*
* @author Michael Bishop
* @link https://gist.github.com/2437076
*
* @global WP_Query $wp_query Query object.