[Support request] Switch nav homepage / inner pages

Home Forums Support Switch nav homepage / inner pages

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #924968
    Dan

    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

    #925026
    Leo
    Staff
    Customer Support

    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 🙂

    #925071
    Dan

    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

    #925078
    Leo
    Staff
    Customer Support

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.