Skip to content

Instantly share code, notes, and snippets.

@cjkoepke
cjkoepke / functions.php
Last active May 3, 2016 03:07
Add custom classes set for Menu items set in Appearance > Custom Menu to the anchor tag.
<?php
//* Do NOT copy the opening PHP tag
add_filter( 'nav_menu_link_attributes', 'ck_attributes_nav_link', 10, 3 );
function ck_attributes_nav_link( $atts, $item, $args ) {
if ( ! $args->menu->name == "Primary Navigation" )
return;
$menu = wp_get_nav_menu_items( 'Primary Navigation' );
@cjkoepke
cjkoepke / functions.php
Last active August 29, 2015 14:27
Add support for structural wraps in Genesis.
<?php
//* Do NOT include the opening PHP tag
$args = array(
'header',
'nav',
'subnav',
'footer-widgets',
'footer',
'site-inner'
@cjkoepke
cjkoepke / functions.php
Last active August 29, 2015 14:27
Add the viewport meta tag to the head of Genesis.
<?php
//* Do NOT include the opening PHP tag
//* Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );
@cjkoepke
cjkoepke / functions.php
Created August 11, 2015 22:18
Add HTML5 Support in Genesis.
<?php
//* Do NOT include the opening PHP tag
$args = array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption'
)
@cjkoepke
cjkoepke / functions.php
Last active August 29, 2015 14:27
Enqueue Google fonts properly in Genesis.
<?php
//* Do NOT include the opening php tag
//* Load Google Fonts
add_action( 'wp_enqueue_scripts', 'ck_load_google_fonts' );
function ck_load_google_fonts() {
wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:400,700|Neuton:400', array(), CHILD_THEME_VERSION );
@cjkoepke
cjkoepke / functions.php
Last active August 29, 2015 14:26
Apply multiple custom classes to the body tag with the body_class filter.
<?php
//* Do NOT include the opening php tag
add_filter( 'body_class', 'ck_custom_body_classes' );
function ck_custom_body_classes( $classes ) {
//* Create an empty value (or add a default to be applied everywhere)
$classes[] = "";
if ( is_front_page() ) {
@cjkoepke
cjkoepke / functions.php
Last active August 29, 2015 14:26
Apply a single custom class to the body element using a filter.
<?php
//* Do NOT copy this line or above
add_filter( 'body_class', 'ck_custom_body_class' );
function ck_custom_body_class( $classes ) {
$classes[] = 'custom-class';
return $classes;
/*
Title: How to Add a Mobile-Friendly, Off Canvas Menu in Genesis
Author: Calvin Koepke (@cjkoepke)
Link: http://www.calvinkoepke.com/add-a-mobile-friendly-off-canvas-menu-in-genesis
*/
/* Animation Settings and Classes
--------------------------------------------- */
.off-canvas-active,
@cjkoepke
cjkoepke / functions.php
Last active November 5, 2015 16:58
Add JavaScript file to our body.
<?php
//* Do NOT include the opening PHP tag
/**
* Include the JavaScript
* @author Calvin Koepke (@cjkoepke)
* @link http://www.calvinkoepke.com/add-a-mobile-friendly-off-canvas-menu-in-genesis
*/
add_action( 'wp_enqueue_scripts', 'ck_load_menu' );
function ck_load_menu() {
jQuery( document ).ready( function( $ ) {
// @author Calvin Koepke (@cjkoepke)
// @link http://www.calvinkoepke.com/add-a-mobile-friendly-off-canvas-menu-in-genesis/
// @version 1.1
// @license Free to use as you wish. Please share if you appreciate and link to the post above.
// Store our jQuery objects as variables
var body = $( 'body' ),
toggleButtons = $( '.menu-btn, .close-btn, .site-overlay' );