Archived topic
Put navigation menu in a hook element generate_inside_container
8 replies · Started by Sam on April 19, 2021
Hello, I am trying to move the navigation to generate_inside_container. Is that possible? Thanks.
Hi there,
try this PHP Snippet:
add_action( 'after_setup_theme','db_move_primary_nav' );
function db_move_primary_nav() {
// remove navigation when set to After header
remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
// add back navigation to inside container
add_action( 'generate_inside_container', 'generate_add_navigation_after_header', 15 );
}
Note this comment: // remove navigation when set to After header - for the code to work the nav must be set to After Header in the Customizer.
Thank you for your quick reply.
I have this error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'generate_inside_container' not found or invalid function name in /public_html/wp-includes/class-wp-hook.php on line 292
My Setting:
No elements.
Customizing - Layout - Header - NOT use navigation as Header / Mobile Header OFF
Customizing - Layout - Primary Navigation - Navigation Location -> Below Header.
Customizing - Layout - Primary Navigation - Sticky Navigation -> OFF.
Thank you very much for your help.
Here is the site
Ooops - made a mistake - i have updated the code above here
Thanks a lot, very helpful! Just one glitch, the <nav></nav> is at the left side of the content area.
<div class="site grid-container container hfeed">
<div class="site-content">
<nav id="site-navigation" class="has-sticky-branding main-navigation sub-menu-right" itemtype="https://schema.org/SiteNavigationElement" itemscope="">
<div class="inside-navigation grid-container">
...
</div>
</nav>
<div class="content-area">
<main id="main" class="site-main">
...
</main>
</div>
</div>
</div>
Try this css:
div#content {
display: flex;
flex-direction: column;
}
Let me know :)
It works, thank you very much.
No problem :)