Different Mobile Nav Menus by Custom Field Section
-
Hello,
I have a theme that originally only supported 2 nav menus.
I needed 4 top nav menus for a website that starts off as an umbrella website and then breaks out into the four company’s under the umbrella site all under the same domain.Section1 is for company A
Section2 is for company B
and so onEach page is related to the menu by custom fields section and then the appropriate value.
To accomplish this:
I have created the following code in functions.php
register_nav_menus( array(
‘section1’ => __( ‘Section 1 Menu’, ‘clinico’),
‘section2’ => __( ‘Section 2 Menu’, ‘clinico’),
‘section3’ => __( ‘Section 3 Menu’, ‘clinico’),
‘section4’ => __( ‘Section 4 Menu’, ‘clinico’),and the following code in header.php
wp_nav_menu( array(
‘theme_location’ => ‘header-menu’,
‘menu_class’ => ‘main-menu’,
‘container’ => false,
‘walker’ => new Cws_Walker_Nav_Menu()
) );
} elseif ( isset( $current_user->roles[0] ) && ‘administrator’ === $current_user->roles[0]) {}
$sectmenu=get_post_meta($post->ID, ‘section’, true);
switch ($sectmenu):
case “1”:
wp_nav_menu( array( ‘theme_location’ => ‘section1’, ‘menu_class’ => ‘main-menu’ ) );
break;
case “2”:
wp_nav_menu( array( ‘theme_location’ => ‘section2’, ‘menu_class’ => ‘main-menu’ ) );
break;
case “3”:
wp_nav_menu( array( ‘theme_location’ => ‘section3’, ‘menu_class’ => ‘main-menu’ ) );
break;
case “4”:
wp_nav_menu( array( ‘theme_location’ => ‘section4’, ‘menu_class’ => ‘main-menu’ ) );
break;endswitch ;
This works great on the desktop side of the site. I’m looking for some insight into how to get it working for the mobile side. Currently, for some unknown reason to me when using a mobile device all pages in company A, B, C, D even though all of their sub-pages use different section #’s 1, 2, 3, 4 I only see the nav menu for section 2 on all pages under all 4 company’s.
Any help would be greatly appreciated.
- The topic ‘Different Mobile Nav Menus by Custom Field Section’ is closed to new replies.