Site logo

Archived topic

Menu issue

3 replies · Started by Sam on April 13, 2022

Viewing posts 1–4 of 4

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

Hi there,

how are you conditionally displaying the different menus ?

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!

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

This archived topic is closed to new replies.