Skip to content

Instantly share code, notes, and snippets.

@rfmeier
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfmeier/8928633 to your computer and use it in GitHub Desktop.
Save rfmeier/8928633 to your computer and use it in GitHub Desktop.
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