Skip to content

Instantly share code, notes, and snippets.

@10h30
Forked from srikat/functions.php
Last active August 29, 2015 14:19
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 10h30/2dd457ef3244ff2b495a to your computer and use it in GitHub Desktop.
Save 10h30/2dd457ef3244ff2b495a to your computer and use it in GitHub Desktop.
Showing a different menu in Primary Navigation location conditionally in Genesis
<?php
//* Do NOT include the opening php tag
add_action( 'genesis_before', 'sk_replace_menu_in_primary' );
/**
* Conditionally replace Custom Menu in Primary Navigation.
*
* @author Sridhar Katakam
* @link http://sridharkatakam.com/conditionally-replace-navigation-menu-genesis/
*/
function sk_replace_menu_in_primary() {
if( is_page( 'about' ) ) { // Put your conditional here
add_filter( 'wp_nav_menu_args', 'replace_menu_in_primary' );
}
}
function replace_menu_in_primary( $args ) {
if ( $args['theme_location'] == 'primary' ) {
$args['menu'] = 'About Page Menu'; // Name of the custom menu that you would like to display in Primary Navigation location when the condition in earlier function is met
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment