Skip to content

Instantly share code, notes, and snippets.

@jmcclellan
jmcclellan / wpseo_breadcrumb_links.php
Created September 28, 2014 01:18
Override Yoast SEO Breadcrumb Trail
@jmcclellan
jmcclellan / Brewfile
Last active July 17, 2019 16:21
New Mac Setup
tap 'caskroom/cask'
tap 'caskroom/fonts'
brew 'git'
brew 'node'
brew 'zsh'
brew 'bash-completion'
brew 'python'
cask '1password'
cask 'agenda'
Array
(
[0] => 479018
[1] => 470821
[2] => 470714
[3] => 470680
[4] => 470549
[5] => 470545
[6] => 470500
[7] => 470498
@jmcclellan
jmcclellan / bootstrapmodalonload
Last active May 25, 2016 07:40
Use cookies to display modal on first visit. Code from http://acooke.web.wesleyan.edu/cookies.html and modified to load bootstrap modal.
<script type="text/javascript">
//<![CDATA[
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
<?php
/* Add a custom field to the field editor (See editor screenshot) */
add_action("gform_field_standard_settings", "my_standard_settings", 10, 2);
function my_standard_settings($position, $form_id){
// Create settings on position 25 (right after Field Label)
if($position == 25){
?>
<li class="admin_label_setting field_setting" style="display: list-item; ">
@jmcclellan
jmcclellan / paginated-posts-advanced.php
Last active December 22, 2015 09:39
Paginated WordPress posts with an option to view as a single post
<?php
/*
----------------------------------------------------------------------------------------------------------
On themes that already have built in support, all you have to do is add <!--nextpage--> via the html
editor on WordPress where you want to add a new page to your post. If your theme doesn't have
intrisic support already built in for this then you can add it with one line:
<?php wp_link_pages(); ?>
References:
@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];
?>
@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 / 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 / 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,