[Resolved] Menu issue

Home Forums Support [Resolved] Menu issue

Home Forums Support Menu issue

  • This topic has 3 replies, 2 voices, and was last updated 2 years ago by David.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2187458
    Sam

    Hi!
    I’m using GP for years and I still love it!

    I found out an issue in one of my sites that I let pass for a year. Shame on me!

    I have two different headers in this site so I can use two different menus and logos: one for the shop and another for the main part of the site.
    In the shop menu I created a menu with submenu items for “Benefícios” (Benefits). All items are wordpress product tags.
    Some of the submenu items show the appropriate menu.
    Examples:
    https://www.sementesdamor.pt/tag/desintoxicacao/
    https://www.sementesdamor.pt/tag/figado/

    Some of the menu items when clicked show the results with the main site menu. This is odd and shouldn’t happen.
    Examples:
    https://www.sementesdamor.pt/tag/sangue/
    https://www.sementesdamor.pt/tag/articulacoes/

    How do I find out what makes this happen?

    I send you a print screen of the header element I created.
    Header Element

    #2187502
    David
    Staff
    Customer Support

    Hi there,

    how are you conditionally displaying the different menus ?

    #2188403
    Sam

    I’m sorry Dave,
    I was checking the conditions in order to answer you… Then I remembered I used the plugin already mentioned here: conditional menus by Themify.

    So it’s not an issue from mighty GP.

    But since I come up with this… Can you guys consider a way for us users to create conditional menus inside a hook? That would be awesome!
    Because, as you can see, the expression “conditional menu” comes up in support forum questions in 12 pages!

    So, you can look at it as a kind of a feature request already!

    Thanks agains Dave!

    #2188415
    David
    Staff
    Customer Support

    Swapping the menus can be done using the wp_nav_menu_args filter.
    For example:

    add_filter( 'wp_nav_menu_args', 'db_switch_menus' );
    
    function db_switch_menus( $args ) {
        if( 'primary' === $args['theme_location'] && is_single() ) { 
            $args['menu'] = '99'; 
        }
        return $args;
    }

    Where primary is the Navigation, and 99 is the ID of the Menu you want displayed if the is_single() condition is met ie. its a Single Post.

    Aside from the nice UI and the complex conditional logic rules that the plugins provide, they probably also deal with transients, caching and a host of other things that should be considered that are out of my pay grade lol

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