Skip to content

Instantly share code, notes, and snippets.

View coffeepostal's full-sized avatar

Adam Farnsworth coffeepostal

View GitHub Profile
@coffeepostal
coffeepostal / jquery.smooth-scrolling-jump-links.js
Created June 8, 2016 17:31
JQUERY: Smooth Scrolling Jump Links
@coffeepostal
coffeepostal / wordpress.custom-post-types-category-in-results.php
Last active July 21, 2016 00:07
WordPress: Adding Custom Post Types to Tag/Category Results
// Adding Custom Post Types to Tag/Category Results
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
// Get all your post types
$post_types = get_post_types();
$query->set( 'post_type', $post_types );
return $query;
}
@coffeepostal
coffeepostal / wordpress.acf.state-list.txt
Created July 28, 2016 18:50
WordPress - Advanced Custom Fields: List of US States, Protectorates/Territories and Military Abbreviations
AL : Alabama
AK : Alaska
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
FL : Florida
GA : Georgia
@coffeepostal
coffeepostal / jQuery.smoothScrolling.js
Created August 25, 2016 16:24
jQuery: Smooth Scrolling to Anchor Links
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
@coffeepostal
coffeepostal / mixin-angled-mask.scss
Created September 25, 2016 20:17
SCSS: Angled Mask
/*********************
ANGLED MASKS
*********************/
@mixin angled-mask($pseudo, $flip: false, $angle: 1.5deg) {
// Possible values for $pseudo are: before, after, both
@if $pseudo == 'before' or $pseudo == 'after' or $pseudo == 'both' {
position: relative;
z-index: 1;
$selector: if($pseudo == 'both', '&:before,&:after', '&:#{$pseudo}');
@coffeepostal
coffeepostal / banner.scss
Last active September 25, 2016 20:22
SCSS: Banner with Edges Cutout
.banner {
height: 0;
transform: translate(0, rem-calc(-24));
border: rem-calc(24) red solid;
border-left: rem-calc(24) transparent solid;
border-right: rem-calc(24) transparent solid;
}
h2 {
margin: 0;
margin-top: rem-calc(-16);
@coffeepostal
coffeepostal / Trianglify.Settings.js
Last active September 29, 2016 22:17
JS: Trianglify Settings
// Multiple DIVs as a true background-image
function addTriangleTo(target) {
var dimensions = target.getClientRects()[0];
var pattern = Trianglify({
width: dimensions.width,
height: dimensions.height
});
target.style['background-image'] = 'url(' + pattern.png() + ')';
}
@coffeepostal
coffeepostal / wordpress.add-custom-image-sizes-to-menu.php
Last active October 8, 2016 17:13
WordPress - functions.php: Add custom images sizes to dropdown media menu
// Add custom image sizes
add_image_size( 'icon', 40, 40, true );
add_image_size( 'icon2x', 80, 80, true );
add_filter('image_size_names_choose', 'my_image_sizes');
function my_image_sizes($sizes) {
$addsizes = array(
"icon" => __( "Icon"),
"icon2x" => __( "Icon@2x")
);
@coffeepostal
coffeepostal / wordpress.add.custom.fields.to.search.php
Last active November 3, 2016 22:19
WordPress: Add Custom Fields to Search
<?php
/**
* Extend WordPress search to include custom fields
*
* http://adambalee.com
*/
/**
* Join posts and postmeta tables
*
@coffeepostal
coffeepostal / scss.vertically.center.mixin.scss
Last active January 18, 2017 23:15
SCSS: Vertically Center Mixin
/* Mixin */
@mixin vertical-align($position: relative) {
position: $position;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.element p {