Skip to content

Instantly share code, notes, and snippets.

@rfmeier rfmeier/functions.php
Last active Aug 29, 2015

Embed
What would you like to do?
Add custom left nav item to Genesis primary menu.
<?php
add_filter( 'wp_nav_menu_items', 'custom_nav_item', 10, 2 );
/**
* Callback for Genesis 'wp_nav_menu_items' filter.
*
* Add custom left nav item to Genesis primary menu.
*
* @package Genesis
* @category Nav Menu
* @author Ryan Meier http://www.rfmeier.net
*
* @param string $menu The menu html
* @param stdClass $args the current menu args
* @return string $menu The menu html
*/
function custom_nav_item( $menu, $args ){
// make sure we are in the primary menu
if ( 'primary' != $args->theme_location )
return $menu;
// see if a nav extra was already specified with Theme options
if( genesis_get_option( 'nav_extras' ) )
return $menu;
// additional checks?
// append your custom code
$menu = sprintf( '<li class="left your-custom-code-class"><span>%s</span></li>', __( 'Your custom code' ) ) . $menu;
// return the menu
return $menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.