Skip to content

Instantly share code, notes, and snippets.

@thecodepoetry
Created December 30, 2014 09:13
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 thecodepoetry/58d76f1ba24c78240514 to your computer and use it in GitHub Desktop.
Save thecodepoetry/58d76f1ba24c78240514 to your computer and use it in GitHub Desktop.
Custom menu filter for The7.2, Armada
add_filter( 'dt_menu_options', 'cp_custom_menu_filter' );
function cp_custom_menu_filter( $options = array() ) {
global $post;
if ( 'primary' == $options['location'] ) {
if(is_page( 35 )) { //if page id 35
$page_primary_menu = intval( 91 ); //display menu with id 91
if ( $page_primary_menu > 0 ) {
$options['params']['menu'] = $page_primary_menu;
$options['params']['dt_has_nav_menu'] = true;
} else {
$options['force_fallback'] = true;
}
}
if(is_page( 45 )) { //if page id 45
$page_primary_menu = intval( 92 ); //display menu with id 92
if ( $page_primary_menu > 0 ) {
$options['params']['menu'] = $page_primary_menu;
$options['params']['dt_has_nav_menu'] = true;
} else {
$options['force_fallback'] = true;
}
}
}
return $options;
}
@thecodepoetry
Copy link
Author

Use this function in functions.php to load different primary menu according to pages (page id 35 will load menu with id 91)

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