This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// equal height containers | |
var contentHeight = $('.content').height(); | |
var sidebarHeight = $('.sidebar').height(); | |
if (contentHeight < sidebarHeight) { | |
$('.content').css('height', sidebarHeight + 'px'); | |
} else { | |
$('.sidebar').css('height', contentHeight + 'px'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// recursively looks for featured images | |
function get_featured_recursive( $post ) { | |
if ( has_post_thumbnail( $post->ID ) ) { | |
return $post->ID; | |
} else if ( $post->post_parent != 0 ) { | |
return get_featured_recursive( get_post( $post->post_parent ) ); | |
} else { | |
return null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // requires php5.3 | |
function add_post_type( $name, $args = array() ) { | |
add_action( 'init', function() use( $name, $args ) { | |
$upper = ucwords( str_replace( '_', ' ', $name ) ); | |
$lower = strtolower( str_replace( '_', ' ', $name ) ); | |
$name = strtolower( str_replace( ' ', '_', $name ) ); | |
$labels = array( | |
'name' => _x( $upper . 's', $name ), | |
'singular_name' => _x( $upper, $name ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*=Search Box | |
-----------------------------*/ | |
#search-box { | |
position:absolute; | |
top:30px; | |
right:80px; | |
} | |
#search-box input[type=text] { | |
font-family:sans-serif; | |
background:#fff; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// custom meta box | |
add_action( 'admin_menu', 'create_meta_box' ); | |
add_action( 'save_post', 'save_meta_box' ); | |
function create_meta_box() { | |
// add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args ); | |
add_meta_box( 'new_meta_box', 'Meta Box Title', 'new_meta_box', 'post_type', 'side', 'low' ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add input placeholder for older browsers | |
(function ($) { | |
"use strict"; | |
if (!Modernizr.input.placeholder) { | |
$('[placeholder]').focus(function () { | |
var input = $(this); | |
if (input.val() === input.attr('placeholder')) { | |
input.val(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Custom fields | |
if ( get_post_meta( $post->ID, 'custom_01', true ) ) { | |
echo get_post_meta( $post->ID, 'custom_01', true ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function register_cpt_slides() { | |
$post_type = 'slides'; | |
$labels = array( | |
'name' => _x( 'Slides', $post_type ), | |
'singular_name' => _x( 'Slide', $post_type ), | |
'add_new' => _x( 'Add New', $post_type ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode( 'basic_shortcode', 'basic_shortcode' ); | |
function basic_shortcode($atts) { | |
$atts = shortcode_atts( | |
array( | |
'title' => 'My Shortcode' | |
), $atts); | |
ob_start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Contain floats: h5bp.com/q */ | |
.group:before, .group:after { content: ""; display: table; } | |
.group:after { clear: both; } | |
.group { *zoom: 1; } |