Skip to content

Instantly share code, notes, and snippets.

@grantambrose
Created September 12, 2016 22:23
Show Gist options
  • Save grantambrose/5be3b8d1ff48030099b6645637079d9b to your computer and use it in GitHub Desktop.
Save grantambrose/5be3b8d1ff48030099b6645637079d9b to your computer and use it in GitHub Desktop.
WordPress: Change the main menu on different pages
// Conditionally change menus
add_filter( 'wp_nav_menu_args', 'bb_wp_nav_menu_args' );
function bb_wp_nav_menu_args( $args = '' ) {
// change the menu in the Header menu position
if( $args['theme_location'] == 'header' && is_page('1159') ) {
$args['menu'] = '32'; // 32 is the ID of the menu we want to use here
}
return $args;
}
@Azrielistic
Copy link

Hello,

Please let me know how I can locate both the wordpress filter and the theme filter. Because I've tried this with my theme but it didn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment