Site logo

Archived topic

Dynamic Secondary Menu

6 replies · Started by Andrew on August 25, 2022

Viewing posts 1–7 of 7

Hey gang.

My client has a business with 3 different sections, each with its own set of pages. I'm looking for a way to add menus dynamically to the Secondary Menu area depending on which area of the site they are viewing. It would be great to do this as an Element using the inside_secondary_menu hook but there's one problem.... If I don't manually assign a menu to the Secondary Menu area then it won't show at all and no dynamic content is visible.

Is there a way to 'force' a secondary menu area to be visible even when empty?

All I can think is to add a dummy menu with display:none as CSS, or maybe a Menu with 'Contact' button. But maybe there's a more elegant GP hook I could use? Maybe is there a way to replace existing content in the Secondary Menu hook with my dynamic content?

Hi Andrew,

Why not just use hook before_header or after_header, and use the WP Navigation Block? Through this, you wouldn’t need to use the Secondary menu.

I did try this in after_header but the container didn't span full width. I will need to add some CSS to get it working properly but if that's the recommended method I could.

I was just wondering it there was an easier way.

.... sorry I did just get it working - I was using after_header_content.

I'm still curious if its possible to force an empty Secondary Menu area hook to be vailable.

Wow that looks great. Thanks Fernando.

You're welcome Andrew!

This archived topic is closed to new replies.