Last active
August 29, 2015 13:56
-
-
Save rfmeier/8928633 to your computer and use it in GitHub Desktop.
Add custom left nav item to Genesis primary menu.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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