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 / year-archive-template.php
Last active January 23, 2021 18:26
Genesis Page Template displaying posts by year. Inspired by Alex Sexton's blog archives: https://alexsexton.com/blog/archives/ and built using code modified from Joe Mar Aparecio: http://www.joemaraparecio.com/customizing-genesis-archive-template-display-posts-month/
<?php
/**
*
* Custom Blog Loop for Bradonomics.
*
* Template Name: Bradonomics Blog
*
*/
//* Remove standard post content output
@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-open-graph.php
Created April 16, 2015 03:52
Adding Open Graph Meta Tags to the Genesis Theme Head
<?php
//* Call the First Image in a Post (Used in the Open Graph Call Below)
function catch_first_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
@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 / skeleton.css
Last active December 16, 2016 14:09
SimpleSheets Grid Changes to Skeleton CSS: https://github.com/dhg/Skeleton
/* Grid
-------------------------------------------------- */
.column {
position: relative;
float: left;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
}
@bradonomics
bradonomics / .gitignore
Last active May 6, 2022 20:25
.gitignore file for Jekyll projects
### Jekyll ###
_site
.jekyll-metadata
*-cache/
### NPM ###
/node_modules/
@bradonomics
bradonomics / .gitignore
Last active December 20, 2016 01:40
.gitignore for WordPress projects.
### Gulp ###
.sass-cache
package.json
/node_modules/
### Atom ###
.ftpconfig
.sftpconfig