Site logo

Archived topic

Switch nav homepage / inner pages

3 replies · Started by Dan on June 10, 2019

Viewing posts 1–4 of 4

I am migrating a site over to GP. On the current site I have a little condition checking which page the user is on and displaying a menu for that page.
Homepage has one menu, all the other pages have a different one.
This is the code I'm currently using:

   <?php if(is_front_page()) { ?>
                 <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
                 <?php } else { ?>
                 <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'menu' => 'main') ); ?>
 <?php } ?>
                

How can this be done with elements?

Thanks,
Dan

Hi Dan,

You will need a plugin like this without some custom development:
https://wordpress.org/plugins/conditional-menus/

Do you only need 2 menus? If so you can maybe use the primary navigation for one and secondary navigation for the second?

If that's the case then you can definitely do it with Layout Element.

Let me know :)

Thanks Leo,
I thought it could be done with code alone without a plugin.
utilizing the code I have above into an hook-element.

Thanks
Dan

Don't believe so.

Tom always suggested using that plugin as well :)

Should see a lot of results if you search the link above in our forum.

Using the secondary nav method should work just as well though.

This archived topic is closed to new replies.