Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View zumwalt's full-sized avatar

Casey Zumwalt zumwalt

View GitHub Profile
@zumwalt
zumwalt / hgtv-slider-conditional
Created December 5, 2012 15:38
HGTV Slider conditional
<li>
<?php if(!get_field("content_1") && (!get_field("content_2")): ?>
// Full width image code
<?php else: ?>
// Regular image code
<?php endif; ?>
</li>
&& - both things
@zumwalt
zumwalt / WP Random Taxonomy
Created January 25, 2013 19:31
A WordPress function for randomly showing a set number of items from a taxonomy. To use, include <?php random_tax(); ?> in your markup.
function random_tax() {
$counter = 0;
$max = 5; // Set max number of items here.
$cats ='';
$categories=get_categories();
$rand_keys = array_rand($categories, $max);
foreach ($rand_keys as $key) {
$cats .= $categories[$key]->term_id .',';
}
@zumwalt
zumwalt / SF Breadcrumbs
Created February 6, 2013 19:28
Breadcrumb function for WordPress
//Breadcrumbs
function sf_breadcrumbs() {
$showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
$delimiter = '>'; // delimiter between crumbs
$home = 'Home'; // text for the 'Home' link
$showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
$before = '<li class="active">'; // tag before the current crumb
$after = '</li>'; // tag after the current crumb
@zumwalt
zumwalt / calc() mixin
Last active December 14, 2015 14:18
Calc mixin for Sass
@mixin calc($property, $expression) {
#{$property}: -moz-calc(#{$expression});
#{$property}: -o-calc(#{$expression});
#{$property}: -webkit-calc(#{$expression});
#{$property}: calc(#{$expression});
}
@zumwalt
zumwalt / is_tree()
Last active October 6, 2017 20:28
is_tree() for WordPress. Good times!
function is_tree( $pid ) { // $pid = The ID of the page we're looking for pages underneath
global $post; // load details about this page
if ( is_page($pid) )
return true; // we're at the page or at a sub page
$anc = get_post_ancestors( $post->ID );
foreach ( $anc as $ancestor ) {
if( is_page() && $ancestor == $pid ) {
return true;
@zumwalt
zumwalt / Vagrantfile
Created April 9, 2013 18:27
Vagrantfile for vagrant-wordpress
Vagrant::Config.run do |config|
config.vm.define :wpvm do |wp_config|
# Box
wp_config.vm.box = "precise32"
# Box URL
wp_config.vm.box_url = "http://files.vagrantup.com/precise32.box"
# Access via IP.
@zumwalt
zumwalt / calc() mixin for less
Last active February 2, 2017 18:30
calc() mixin for less
.calc(@expression) {
width: -moz-calc(@expression);
width: -o-calc(@expression);
width: -webkit-calc(@expression);
width: calc(@expression);
}
@zumwalt
zumwalt / Focus scroll
Created July 19, 2013 20:22
Keeps the window/body from scrolling while you're focused on a fixed/absolute element that also scrolls.
$('#element').bind('mousewheel DOMMouseScroll', function(e) {
var scrollTo = null;
if (e.type == 'mousewheel') {
scrollTo = (e.originalEvent.wheelDelta * -1);
}
else if (e.type == 'DOMMouseScroll') {
scrollTo = 40 * e.originalEvent.detail;
}
@mixin icon-setup($icon, $width, $height, $padding:"") {
padding-left: $width + 9;
position: relative;
&:before {
@include icon-sprite($icon);
content: '';
display: inline-block;
height: $height;
left: 5px;
position: absolute;
@mixin rotated-text($num-letters: 100, $angle-span: 180deg, $angle-offset: 0deg) {
$angle-per-char: $angle-span / $num-letters;
@for $i from 1 through $num-letters {
.char#{$i} {
@include transform(rotate($angle-offset + $angle-per-char * $i));
}
}
}