Last active
October 29, 2018 14:36
-
-
Save rfmeier/5735579 to your computer and use it in GitHub Desktop.
Add custom 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 | |
//* do no include php tags | |
add_filter( 'wp_nav_menu_items', 'custom_nav_item', 10, 2 ); | |
/** | |
* Callback for Genesis 'wp_nav_menu_items' filter. | |
* | |
* Add custom right 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="right your-custom-code-class">%s</li>', __( 'Your custom code' ) ); | |
return $menu; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment