Skip to content

Instantly share code, notes, and snippets.

@jmcclellan
jmcclellan / soliloquy slider overrides.less
Last active August 29, 2015 13:56
Soliloquy nested LESS/SCSS classes
.soliloquy-container {
.soliloquy {
ul.soliloquy-slides {
li.soliloquy-item {
img.soliloquy-item-image {
// make sure the image fills the width of the container
@jmcclellan
jmcclellan / equal-height-columns.js
Created February 7, 2014 18:10
Use jQuery to create equal height columns
function setEqualHeight(columns) {
// define our variables
var tallestcolumn = 0;
var currentHeight = 0;
// .each() iterates over a jquery object (in this case our columns argument)
columns.each(
function() {
// assign currentHeight variable the height of the current DOM element in our loop
currentHeight = jQuery(this).height();
// is the currentHeight variable larger than the currentHeight variable?
@jmcclellan
jmcclellan / gist:5e7c1b45c2e832fcfba6
Created June 20, 2014 04:59
Call the Ustream Channel API to see if a channel is live
// CUSTOM CODE that checks ustream and displays banner if it's live
// GET URL represented as https://api.ustream.tv/channels/CHANNEL_ID.json
$.getJSON('https://api.ustream.tv/channels/5817556.json', function(data)
{
// if the channel status is live then do something
if (data.channel.status == 'live')
{
// alert('Its live!');
}
});
@jmcclellan
jmcclellan / script.js
Last active August 29, 2015 14:05
Open nav menu on hover instead of click when using the Roots framework
// add open class to dropdown menu when hovered over
$(function() {
$(".dropdown").hover(
function(){ $(this).addClass('open'); },
function(){ $(this).removeClass('open'); }
);
});
@jmcclellan
jmcclellan / gist:5572683
Last active December 17, 2015 07:28 — forked from johnsparrow/gist:5572286
Custom post type loop with optional extra arguments
<?php
function do_custom_pt_query( $args = array() ){
global $post;
$def_args = array('post_type' => 'on_air_programs',
'numberposts' => -1,
'posts_per_page' => -1,
@jmcclellan
jmcclellan / paginatelinks.php
Created May 22, 2013 16:33
Wordpress Paginate Links
@jmcclellan
jmcclellan / social.html
Created May 24, 2013 16:37
Javascript-less social links
<!-- Twitter -->
<a href="https://twitter.com/intent/tweet?original_referer={REFERRER_URL}&source=tweetbutton&text={{TWEET_TEXT}}&url={URL}&via=MrMartineau" title="Tweet this">Tweet this</a>
<!-- Facebook -->
<a href="http://www.facebook.com/share.php?u={URL}&t={TITLE}">Share on Facebook</a>
<!-- Google plus -->
<a href="https://plus.google.com/share?url={URL}">Google+</a>
<a href="https://plus.google.com/share?url={URL}" onclick="javascript:window.open(this.href,
@jmcclellan
jmcclellan / gist:5675863
Last active December 17, 2015 21:39
Wordpress - Add CSS class to every fourth post
<?php if (have_posts()) : ?>
<?php
// declare counter variable and assign it a value of 0
$count = 0;
?>
<?php while (have_posts()) : the_post(); ?>
<?php if ($count % 4 == 3) { echo '<div class="post className">'; } else { echo '<div class="post>'; } ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
@jmcclellan
jmcclellan / category-breadcrumb.php
Last active December 18, 2015 00:59
Outputs a category breadcrumb with a parent/child relationship. This code will only work flawlessly if there is only one category selected on the post.
<?php
function somesite_cat_breadcrumb() {
// variables
$category = get_the_category();
$catParID = $category[0]->category_parent;
$catParent = get_cat_name($catParID);
$catName = $category[0]->cat_name;
// filter breadcrumb for posts with no parent categories versus those with 1 or more parent categories and
// then display the immediate parent category (if applicable) followed by the current (or first) post category
@jmcclellan
jmcclellan / post_thumbnail_url.php
Created August 6, 2013 03:21
Wordpress: get the post thumbnail URL
<?php
// Use this to retrieve the URL of the featured post thumbnail.
// You can change the 'thumbnail' part to any wordpress image size (eg full, medium, thumbnail, etc.).
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'thumbnail', true);
echo $thumb_url[0];
?>