Skip to content

Instantly share code, notes, and snippets.

@nathanrice
nathanrice / jetpack-open-graph-tags.php
Last active December 12, 2015 00:28
Use Genesis Doctitle and Meta Description with Jetpack's Open Graph tags on entry pages.
<?php
add_filter( 'jetpack_open_graph_tags', 'nr_jetpack_open_graph_tags_filter' );
/**
* Filter open graph tags to use Genesis doctitle and meta description instead.
*
* @author Nathan Rice
* @link https://gist.github.com/4683845
*/
function nr_jetpack_open_graph_tags_filter( $tags ) {
<?php
//** Redirect if not logged in
if ( ! is_user_logged_in() && 'wp-login.php' !== $pagenow ) {
wp_redirect( wp_login_url() );
exit;
}
@nathanrice
nathanrice / single-recipe.php
Created May 16, 2013 14:36
A sample single template for a Recipe CPT with Genesis
<?php
/**
* This file controls the single view of the Recipe CPT
*/
/**
* This is where you would put your custom mods. Just hook them (or unhook) to the proper location.
*/
genesis(); //* <-- Just make sure this is at the END of the file.
@nathanrice
nathanrice / .profile
Last active December 17, 2015 22:09
Convert GitHub issue into a Pull Request
# Replace [username] with your GitHub username (in both places).
# Replace [project]/[repository] with the project and repository where the issue resides.
# Replace [base] with the destination branch you wish to PR to (usually master or develop)
# And obviously, don't leave the [] brackets in there.
# Usage:
# @git-pr 999 features/999
@nathanrice
nathanrice / functions.php
Created August 2, 2013 20:05
Unit test for HTML5 support in WordPress 3.6
<?php
//* Only turn on HTML5 for comment list
add_theme_support( 'html5', array( 'comment-list' ) );
@nathanrice
nathanrice / gist:9399581
Created March 6, 2014 21:03
Debug rogue redirects in WordPress
<?php
//* Debug redirect
add_filter( 'wp_redirect', function( $location ) {
if ( home_url() == $location ) {
print_r( debug_backtrace() );
return false;
}
@nathanrice
nathanrice / fruits.php
Created March 7, 2014 17:03
Example of unset not working properly
<?php
class Fruit_List {
private $fruit = array();
function __construct() {
$this->add_fruit( array(
1 => 'apple',
2 => 'orange',
<?php
//* Do NOT include the opening php tag
add_filter( 'stylesheet_uri', 'custom_replace_default_style_sheet', 10, 2 );
/**
* Replace main theme style sheet with custom one if viewing post in a particular category.
*
* Note: Replace X with the category ID you want to target.
*/
function custom_replace_default_style_sheet( $stylesheet, $stylesheet_dir ) {
@nathanrice
nathanrice / functions.php
Created May 28, 2015 16:33
Enable Genesis Accessibility
//* Add Accessibility support
add_theme_support( 'genesis-accessibility', array( 'headings', 'drop-down-menu', 'search-form', 'skip-links' ) );
@nathanrice
nathanrice / style.css
Created May 28, 2015 16:34
Style new Genesis Accessibility output
/* ## Screen reader text
--------------------------------------------- */
.screen-reader-text,
.screen-reader-text span,
.screen-reader-shortcut {
position: absolute !important;
clip: rect(0, 0, 0, 0);
height: 1px;
width: 1px;