Skip to content

Instantly share code, notes, and snippets.

@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: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
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
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
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 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
Created November 15, 2015 20:45
Limit a specified menu to a specified depth.
<?php
//* Do NOT copy the opening PHP tag
//* Set menu depth to one level
add_filter( 'wp_nav_menu_args', 'ck_limit_nav_depth' );
function ck_limit_nav_depth( $args ) {
if( $args['theme_location'] == 'primary' )
$args['depth'] = 1;
@cjkoepke
cjkoepke / style.css
Last active November 15, 2015 22:45
Apply a fixed nav to the left of the viewport. Styled to accommodate Icons in the menu.
/* Primary Navigation
--------------------------------------------- */
.nav-primary {
background-color: #242831;
height: 100%;
left: 0;
position: fixed; /* Make our navigation stick to the left of the viewport at all times */
top: 0;
width: 80px;
@cjkoepke
cjkoepke / style.css
Created November 15, 2015 22:26
Adjust site structure and container to accommodate for an 80px wide left sidebar menu.
/* Container
--------------------------------------------- */
.site-container {
margin-left: 80px; /* Compensate for 80px side nav */
}
.site-inner,
.wrap {
max-width: 1120px; /* Compensate for 80px side nav */
@cjkoepke
cjkoepke / style.css
Created November 15, 2015 22:47
Add animation to our left sidebar menu, emphasis on icons.
/* Primary Navigation - Animated
--------------------------------------------- */
.nav-primary .genesis-nav-menu a,
.nav-primary .genesis-nav-menu a:before,
.nav-primary .genesis-nav-menu .menu-item {
-webkit-transition: all .10s ease-in-out;
-moz-transition: all .10s ease-in-out;
-ms-transition: all .10s ease-in-out;
-o-transition: all .10s ease-in-out;