Create Alternate Menus

If you need alternate primary menus on pages, you can do the following. (Substitute Menu 1, Menu 2, Menu 3 for the menus you want to create.)

1 – Install the Advanced Custom Fields plugin.

2 – Create a Field Group with a Radio Button field labeled Menu Choice.

3 – For the field values, enter:

primary : Primary
menu1 : Menu 1
menu2 : Menu 2
menu3 : Menu 3

acf-menu-choices

4 – Be sure to select select the location you want these options to display on:

acf-location

Publish the Field Group.

5 – These choices will now display on the Edit Page below the main content area. (Tip: You can also specify in the Advanced Custom Fields settings where on the Edit Page you’d like these to display.)

6 – Add the following functions to your child theme’s functions.php file below the require_once line:

/*-------------------------------------------------------*/
/* Create Alternate Menus
/*-------------------------------------------------------*/

/* Register new menu locations that display on Appearance > Menus */
	
register_nav_menus( array(
	'menu1' => 'Menu 1',
	'menu2' => 'Menu 2',
	'menu3' => 'Menu 3',
) );

/* Get custom field "menu_choice" and add to TB menu location filter */

function my_menu( $args ) {
	
	$altmenu = get_field('menu_choice');
	$args = $altmenu;
	return $args;

}

add_filter( 'themeblvd_primary_menu_location', 'my_menu' );

7 – Define your menus under Appearance > Menus and assign them to the correct Menu Location:

menus

8 – Edit your pages and select the alternate menu for the page:

menus