Archived topic
Secondary Menu Search and offcanvas menu
5 replies · Started by Nathan on February 23, 2021
I am trying to get my search and offcanvas menu in the secondary menu. like the following https://www.screencast.com/t/4VUTcUHa, I found the doc on using the Nav search in secondary nav, but that only works if there is an actual menu there as well. https://docs.generatepress.com/article/navigation-search/
Is there an option to move the offcanvas menu to the secondary menu and if so, will it correct the search issue?
Hi there,
As more moving the search icon/bar to the secondary navigation:
This snippet should work if you're using Flexbox on Appearance > Customize > General.
add_action( 'wp', function() {
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' );
add_action( 'generate_secondary_menu_bar_items', 'generate_do_navigation_search_button' );
}
}, 20 );
As for making the secondary navigation work as a offcanvas toggle, this will be quite tricky. You may have to resort to scripting to make it work.
So again, that only works if there is a secondary menu assigned - https://www.screencast.com/t/GOLHYOGmrx
If no menu assigned the search does not appear. https://www.screencast.com/t/GOLHYOGmrx
Hi there,
create a blank Menu ( ie. has no menu items ) for the Secondary Nav.
Thanks @david thats one way to get around it. Not sure GP will work for project unless I can get off canvas menu in the secondary position as well.
See this topic:
If not the alternative method is to swap the Primary and Secondary Navigations.