Skip to content

Instantly share code, notes, and snippets.

View bradonomics's full-sized avatar

Brad West bradonomics

View GitHub Profile
@bradonomics
bradonomics / genesis-sample-page
Last active August 29, 2015 14:10
This is a page sample for Genesis. A visual look can be found here: http://www.genesisframework.com/markup.php
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Blog Post Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name='robots' content='index,follow' />
<link rel="alternate" type="application/rss+xml" title="WordPress Weblog &raquo; Feed" href="http://wordpressweblog.org/feed/" />
<link rel="alternate" type="application/rss+xml" title="WordPress Weblog &raquo; Comments Feed" href="http://wordpressweblog.org/comments/feed/" />
@bradonomics
bradonomics / post_book_template.php
Last active August 29, 2015 14:16
Custom Post Template for Book Reviews. Uses Advanced Custom Fields plugin: https://wordpress.org/plugins/advanced-custom-fields/ and Single Post Template plugin: https://wordpress.org/plugins/single-post-template/
<?php
/*
* Single Post Template: Book Review
*
*/
//* Add Aside for Buy the Book Info
add_action( 'genesis_entry_content', 'bw_book_review', 30 );
function bw_book_review() {
@bradonomics
bradonomics / remove-inline-image-widths.php
Last active August 29, 2015 14:18
Strip inline width styles from WordPress's image caption shortcodes to allow for responsive images.
//* Strip width from image captions to allow responsive code to shrink images.
add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
add_shortcode('caption', 'fixed_img_caption_shortcode');
function fixed_img_caption_shortcode($attr, $content = null) {
if ( ! isset( $attr['caption'] ) ) {
if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is',
$content, $matches ) ) {
$content = $matches[1];
$attr['caption'] = trim( $matches[2] );
}
@bradonomics
bradonomics / tag-cloud-number.php
Created April 10, 2015 03:18
Limit the number of tags in the tag cloud widget
//* Limit the number of tags in the tag cloud widget
add_filter( 'widget_tag_cloud_args', 'my_widget_tag_cloud_args' );
function my_widget_tag_cloud_args( $args ) {
$args = array(
'number' => 32,
);
return $args;
}
@bradonomics
bradonomics / genesis-image-above-content.php
Last active October 17, 2015 07:45
This code is for the Genesis Framework and, as written, will not work on any other WordPress installation. I was looking for a way to add an image larger than the content area above the content area yet below the post title. Add the code in the functions.php file to your child theme functions file and when a post has a featured image it will pul…
<?php
//* Adds Feature Image before entry-content tag
add_action ( 'genesis_entry_header', 'bw_featured_image' );
function bw_featured_image() {
if ( !is_singular() || !has_post_thumbnail() )
return;
echo '<div class="featured-image">';
genesis_image( array( 'size' => 'singular' ) );
$args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'numberposts' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
@bradonomics
bradonomics / language-learning
Last active December 14, 2015 02:18
Jekyll Categories on GitHub Pages (_pages/language-learning.md)
---
layout: category
title: Language Learning
description: Some thoughts on adult language learning that fall outside the standard techniques of translation and grammar study.
category: language learning
permalink: /language-learning/
---
If you were hoping for some original research, sadly I have none. What follows has already been written about elsewhere and by people far smarter than me. What I hope to bring to the conversation is a simplified version of their work and my story in discovering it. But more importantly, I hope to introduce you to some thoughts on adult language learning that fall outside the standard techniques of translation and grammar study.
@bradonomics
bradonomics / post-categories.html
Last active December 14, 2015 02:45
Jekyll Categories on GitHub Pages (multiple categories) (_includes/post-categories.html)
{% if post %}
{% assign categories = post.categories %}
{% else %}
{% assign categories = page.categories %}
{% endif %}
{% for category in categories %}
<span class="entry-categories"><a href="{{ site.url }}/{{ page.category-url }}/" rel="category">{{ page.category }}</a></span>{% unless forloop.last %},{% endunless %}
{% endfor %}
@bradonomics
bradonomics / post-categories.html
Created December 14, 2015 02:46
Jekyll Categories on GitHub Pages (single category) (_includes/post-categories.html)
<span class="entry-categories"><a href="{{ site.url }}/{{ page.category-url }}/" rel="category">{{ page.category }}</a></span>
@bradonomics
bradonomics / install.sh
Created April 13, 2016 09:49
Installation script for Genesis Boilerplate (or how to start a Genesis child theme). See bradonomics.com/genesis-boilerplate/ for instructions.
#!/bin/bash
# Download boilerplate files
wget https://github.com/bradonomics/genesis-boilerplate/archive/master.tar.gz
# Unzip
tar zxf master.tar.gz
cd genesis-boilerplate-master
cp -rpf * ../
cp -rpf .[^.]* ../ # moves .gitignore
@bradonomics
bradonomics / install.sh
Last active May 3, 2016 08:26
Installation script for Jekyll Boilerplate (or how to start a Jekyll theme). See github.com/bradonomics/jekyll-boilerplate#readme for instructions.
#!/bin/bash
# Download boilerplate files
wget https://github.com/bradonomics/jekyll-boilerplate/archive/master.tar.gz
# Unzip
tar zxf master.tar.gz
cd jekyll-boilerplate-master
cp -rpf * ../
cp -rpf .[^.]* ../ # moves .gitignore