Site logo

Archived topic

Most GP-friendly way to modify primary menu

3 replies · Started by Bret on September 21, 2020

Viewing posts 1–4 of 4

I've got a customer requirement that says display a different menu if a user is logged in.

In some themes, there's a navigation snippet that can be copied into the child theme.

   if (is_home()) {
        wp_nav_menu( array(
                'theme_location' => 'header-menu',
                'menu'           => 'blog-menu',
                'container'              => false,
                'fallback_cb'    => '',
                'menu_class'     => 'primary-menu bb-primary-overflow', )
        );

   } else {
        wp_nav_menu( array(
                'theme_location' => 'header-menu',
                'menu_id'                => 'primary-menu',
                'container'              => false,
                'fallback_cb'    => '',
                'menu_class'     => 'primary-menu bb-primary-overflow', )
        );
   }

In GP, this is all in the navigation.php, which is ~400 lines of code and I don't think I really want it in my child theme.

Is there a GP-friendly way to accomplish this?

Hacky ideas include generating all possible menu sites, and then using conditional javascript to hide them.

OK will give it a try!

Sounds good :)

This archived topic is closed to new replies.