Skip to content

Instantly share code, notes, and snippets.

View reediredale's full-sized avatar

Reed Iredale reediredale

View GitHub Profile
@reediredale
reediredale / Custom Post Type - Category List
Created June 28, 2012 02:20
Displaying Custom WordPress Taxonomy List Items Without the Links
<?php $terms_as_text = get_the_term_list( $post->ID, 'filter', '', ', ', '' ) ;
echo strip_tags($terms_as_text); ?>
@reediredale
reediredale / Custom Post Type Setup
Created June 28, 2012 02:24
Custom Post Type - (eg. Portfolio)
<?php
// function: post_type BEGIN
function post_type()
{
// Create The Labels (Output) For The Post Type
$labels =
array(
// The plural form of the name of your post type.
'name' => __( 'Portfolio'),
@reediredale
reediredale / gist:3008371
Created June 28, 2012 02:26
Custom Post Type Loop
<ul class="filterable-grid clearfix">
<?php $wpbp = new WP_Query(array( 'post_type' => 'portfolio', 'posts_per_page' =>'-1' ) ); ?>
<?php if ($wpbp->have_posts()) : while ($wpbp->have_posts()) : $wpbp->the_post(); ?>
<?php $terms = get_the_terms( get_the_ID(), 'filter' ); ?>
<li data-id="id-<?php echo $count; ?>" data-type="<?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>">
@reediredale
reediredale / gist:3008381
Created June 28, 2012 02:28
Register WP Theme Scripts
// Register our Scripts
function register_js() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
wp_register_script('quicksand', get_template_directory_uri() . '/js/jquery.quicksand.js', 'jquery');
wp_register_script('easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', 'jquery');
wp_register_script('custom', get_template_directory_uri() . '/js/jquery.custom.js', 'jquery', '1.0', TRUE);
wp_register_script('prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', 'jquery');
@reediredale
reediredale / gist:3009052
Created June 28, 2012 04:20
WordPress Portfolio Custom Post Type Filtering
<?php
// get portfolio
$args = array( 'post_type' => 'portfolio', 'posts_per_page' => 100, 'orderby' => 'title', 'order' => 'asc' );
$loop = new WP_Query( $args );
$port = array();
while ( $loop->have_posts() ) : $loop->the_post();
$idx = get_the_ID();
$year_completed = get_post_meta($idx, 'year_completed', true);
$website_addr = get_post_meta($idx, 'website_address', true);
$thumb = get_the_post_thumbnail($idx, 'thumbnail'); //250x200 - featured image
@reediredale
reediredale / gist:3015234
Created June 29, 2012 02:11
Using the same template across multiple category, tag, and author pages
?php
// Inspired by a snippet by Justin Tadlock (http://justintadlock.com/) posted here: http://elliotjaystocks.com/blog/tutorial-multiple-singlephp-templates-in-wordpress/#comment-2383
add_filter( 'category_template', 'my_category_template' );
// I believe *_template hooks exist for just about every type of template so it's easy to apply to other templates as well
function my_category_template( $template ) {
if( is_category( 1 ) ) // We can search for categories by ID
$template = locate_template( array( 'template_id_A.php', 'category.php' ) );
@reediredale
reediredale / gist:3015310
Created June 29, 2012 02:31
HTML5 Image Swap
<figure class="swapimage">
<img src="<?php $image = get_post_meta($post->ID, 'normal', true); ?><?php echo $image; ?>" alt="" />
<img src="<?php $hover = get_post_meta($post->ID, 'hover', true); ?><?php echo $hover; ?>" class="swap-target" alt="" />
</figure>
@reediredale
reediredale / gist:3015313
Created June 29, 2012 02:32
HTML5 Image Swap CSS
.swapimage {
display: block;
position: relative;
margin: 0px;
padding: 0px;
transition: all 2s;
margin-bottom: 12px;
border: 1px solid #fff;
}
@reediredale
reediredale / gist:3063326
Created July 6, 2012 23:14
Category without parent or links
<?php $categories = get_the_category();
$temp = array();
foreach($categories as $category) {
if ($category->category_parent == 0) continue;
$temp[] = str_replace('-', '', $category->name);
@reediredale
reediredale / gist:3088203
Created July 11, 2012 05:41
Equal Columns Script
function setEqualHeight(columns)
{
var tallestcolumn = 0;
columns.each(
function()
{
currentHeight = $(this).height();
if(currentHeight > tallestcolumn)
{
tallestcolumn = currentHeight;