Skip to content

Instantly share code, notes, and snippets.

View jaredkc's full-sized avatar

Jared Cornwall jaredkc

  • Salt Lake City, UT
View GitHub Profile
@jaredkc
jaredkc / functions.php
Last active August 29, 2015 14:26
Styles for the WordPress login screen (`/wp-login.php`)
/**
* Styles for the login screen
*/
function _login() {
wp_enqueue_style( 'login', get_template_directory_uri() . '/assets/css/login.css' );
}
add_action( 'login_enqueue_scripts', '_login' );
@jaredkc
jaredkc / newwindow.js
Created June 15, 2015 22:01
Open all external links in a new window
(function($) {
$(document).ready(function() {
/**
* Open all external links in a new window/tab
*/
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
@jaredkc
jaredkc / faq-post-type.php
Created December 16, 2014 22:13
Basic setup for FAQ custom post type in WordPress
<?php
/**
* Post type to manage a list of frequently asked questions.
*
* @package rho
*/
if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
if ( ! class_exists( 'FAQ_Post_Type' ) ) :
@jaredkc
jaredkc / gist:3d701e7c66fc51269adf
Created December 10, 2014 01:36
Sass Retina Sprite Mixin
// --------------------------------------------------
// Sprite along with retina version.
// --------------------------------------------------
@mixin sprite($xpos, $ypos, $width: 600px, $height: 600px) {
background-image: url(../img/sprite.png);
background-position: $xpos $ypos;
background-repeat: no-repeat;
// Solution for retina graphics.
// Variation of: http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss
@media (min--moz-device-pixel-ratio: 1.3),
@jaredkc
jaredkc / wp_featured_post.php
Created November 3, 2014 20:51
WordPress Featured Post
/**
* Display the most recent post in the "featured" category and
* keep if from showing in the default loop on the same page.
*/
function jkc_featured_post() {
$featured_query = new WP_Query( array(
'category_name' => 'featured',
'posts_per_page' => '1',
'orderby' => 'modified'
) );
@jaredkc
jaredkc / aspect-ratio.css
Created October 24, 2014 03:23
Responsive Aspect Ratio
[class^="ratio-"], [class*=" ratio-"] {
height: 0;
}
.ratio-21x9 {
padding-bottom: 42.86%;
}
.ratio-16x9 {
padding-bottom: 56.25%;
}
.ratio-4x3 {
@jaredkc
jaredkc / vertical-center.css
Last active August 29, 2015 14:08
CSS vertically align center
.vcenter-wrap {
display: table;
height: 100%;
}
.vcenter {
display: table-cell;
vertical-align: middle;
}
@jaredkc
jaredkc / wp-link-less-categories.php
Created July 11, 2014 14:56
Output the WordPress categories without links.
@jaredkc
jaredkc / gitconfig-alias.sh
Last active August 29, 2015 14:01
A list of my Git aliases
[alias]
st = status
co = checkout
cm = commit
pr = pull --rebase
# Start over
fuckit = reset --hard
# Submodules
subup = submodule update --init --recursive
# Show verbose output about tags, branches or remotes
@jaredkc
jaredkc / group-posts-by-terms.php
Last active February 19, 2025 22:44
Wordpress: get posts and group by taxonomy terms.
/**
* Get posts and group by taxonomy terms.
* @param string $posts Post type to get.
* @param string $terms Taxonomy to group by.
* @param integer $count How many post to show per taxonomy term.
*/
function list_posts_by_term( $posts, $terms, $count = -1 ) {
$tax_terms = get_terms( $terms, 'orderby=name');
$args = array(