Skip to content

Instantly share code, notes, and snippets.

View gregrickaby's full-sized avatar
:octocat:

Greg Rickaby gregrickaby

:octocat:
View GitHub Profile
@gregrickaby
gregrickaby / sticky-cpt.php
Last active August 29, 2015 14:01
Make a CPT post sticky anytime it's updated
<?php
add_action( 'save_post', 'child_sticky_factory', 99 );
/**
* Allow sticky posts in a CPT
*/
function child_sticky_factory() {
$post_id = get_the_ID();
$stickem = get_post_meta( $post_id, '_child_sticky', true );
@gregrickaby
gregrickaby / social-icons-widget.php
Last active August 29, 2015 14:03
Social Icons Widget
<?php
/*
Plugin Name: Social Icons Widget
Description: A simple widget to display social icons from Font Awesome.
Version: 1.0.0
Author: Greg Rickaby
Author URI: http://gregrickaby.com
License: GPLv2
Text Domain: textdomain
*/
@gregrickaby
gregrickaby / functions.php
Last active August 29, 2015 14:03
How to create an Author Box using the Gravatar API
<?php
// DO NOT INCLUDE OPENING PHP TAG AND PLACE INTO FUNCTIONS.PHP
/**
* Get Author's Gravatar profile data.
*/
function custom_get_gravatar_profile() {
// Get author data
$author = strtolower( trim( get_the_author_meta( 'email' ) ) );
@gregrickaby
gregrickaby / functions.php
Created August 4, 2014 21:07
Auto check the "Open link in a new window/tab" checkbox in WordPress
<?php
// DO NOT INCLUDE THE OPENING PHP TAG AND INSERT INTO FUNCTIONS.PHP
add_action( 'admin_footer', 'custom_new_link_auto_check', 9999 );
/**
* Auto check the "Open link in a new window/tab" modal
*/
function custom_new_link_auto_check() { ?>
<script type="text/javascript">
@gregrickaby
gregrickaby / recent-post-widget.php
Last active August 29, 2015 14:06
Recent Post Widget
<?php
/*
Plugin Name: Recent Posts Widget
Plugin URI: http://gregrickaby.com
Description: Display recent posts in a widget area.
Version: 1.0.0
Author: Greg Rickaby
Author URI: http://gregrickaby.com
License: GPLv2
Text Domain: textdomain
@gregrickaby
gregrickaby / hamburger-nav.html
Created September 12, 2014 14:26
Über basic Hamburger Nav...seriously feel free to contribute and make this suck less.
<!-- The website logo and hamburger icon -->
<div class="mobileNavWrap">
<div class="mobileLogo">
<a href="#"><img src="/some-logo.png" alt="some website" height="100" width="100" /></a>
</div>
<div id="mobileNavIcon">
&#x2261;
</div>
</div>
@gregrickaby
gregrickaby / web.config
Last active August 29, 2015 14:15
IIS 8.5 WordPress Multisite Rewrite Rules
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false" />
<action type="None" />
</rule>
<rule name="WordPress Rule 2" stopProcessing="true">
/**
* fixMSWord
*
* Replace ascii chars with utf8. Note there are ascii characters that don't
* correctly map and will be replaced by spaces.
*
* Updated 7-15-2015 by Jay Wood to encode lower end items into HTML entity counterparts.
*
* @author Robin Cafolla,Jay Wood
* @date 2013-03-22
@gregrickaby
gregrickaby / home.php
Created February 13, 2012 20:30
Genesis Custom Loop w/ Featured Image
<?php $loop_2 = new WP_Query( 'cat=1&showposts=2&orderby=date&order=DESC' ); while ($loop_2->have_posts()) : $loop_2->the_post(); ?>
<div <?php post_class(); ?>>
<div class="column-5 left">
<a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail( 'thumbnail', array( 'class' => 'featured-image' ) ); ?></a>
<a href="<?php the_permalink(); ?>" /><span class="read-more">Read More</span></a>
</div>
<div class="column-6 right">
<h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php
/**
* Adds Radio Latest News Widget.
*
* @package Radio
* @package Widgets
* @author Greg Rickaby, Justin Sternberg (@Jtsternberg), Travis Smith (@wp_smith), and StudioPress
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
* @link http://www.studiopress.com/themes/genesis
*/