Archived topic
Disable second nav menu on a single page
9 replies · Started by Paul on November 25, 2021
I have the following page which is to be read by another system and I need to keep the page as lean as possible.
Using another plugin (I don't know if GP can strip out unused css/javascript?) I've managed to make the page fairly lean, however I'm still getting my Second nav menu displayed.
Is there a way I can turn this off e.g. not outputted rather than hiding it
Hi there,
you can use the Disable Elements Meta Box in the page editor:
https://docs.generatepress.com/article/disable-elements-overview/
The list will include the Secondary Nav for sites with it enabled.
I have used that feature and the menu still appears.
Does that actually stop the output of the HTML code?
I say that, as I've disabled lots of javascript/css being outputted with the other plugin - could that be to blame? If so, do you know what?
The Disable Elements is a server side function (PHP) that will unhook that template part / function. So there should be no HTML output at all.
If its not going away then try clearing any server side page caches.
If its still not working then there must be some other function or changes to the template affecting that
I found that toggling the inclusion of "/wp-content/themes/generatepress/assets/css/style.min.css" made the menu appear or not.
Searching the source I can see that the menu HTML has been output...
<button class="menu-toggle secondary-menu-toggle">
<span class="mobile-menu">Menu</span> </button>
<div class="main-nav"><ul id="menu-top-bar-menu" class=" secondary-menu sf-menu"><li id="menu-item-9044" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9044"><a href="https://www.suddencardiacarrestuk.org/shop/">Shop</a></li>
<li id="menu-item-9045" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9045"><a href="https://www.suddencardiacarrestuk.org/donate/">Donate</a></li>
<li id="menu-item-9046" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9046"><a href="https://www.suddencardiacarrestuk.org/about-us/">About</a></li>
<li id="menu-item-9047" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9047"><a href="https://www.suddencardiacarrestuk.org/contact/">Contact</a></li>
<li id="menu-item-9048" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9048"><a href="https://facebook.com/SuddenCardiacArrestUK"><i class="_mi dashicons dashicons-facebook" aria-hidden="true" style="font-size:1.8em;"></i></a></li>
<li id="menu-item-9049" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9049"><a href="https://twitter.com/WeAreSCAUK"><i class="_mi dashicons dashicons-twitter" aria-hidden="true" style="font-size:1.8em;"></i></a></li>
<li id="menu-item-9109" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9109"><a href="https://www.youtube.com/channel/UCJkb9cJprDJc8XokVMo8ENw"><i class="_mi dashicons dashicons-youtube" aria-hidden="true" style="font-size:1.8em;"></i></a></li>
<li id="menu-item-13021" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-13021"><a href="https://www.instagram.com/suddencardiacarrestuk/"><i class="_mi dashicons dashicons-instagram" aria-hidden="true" style="font-size:1.8em;"></i></a></li>
</ul></div> </div>
Do you have any custom functions or hook elements running on the site ?
I have one hook to add a yoast breadcrumb. The page wasn't excluded, but it is now and the mobile menu is still in the code
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '
' );
}
?>
<button class="menu-toggle secondary-menu-toggle">
<span class="mobile-menu">Menu</span> </button>
<div class="main-nav"><ul id="menu-top-bar-menu" class=" secondary-menu sf-menu"><li id="menu-item-9044" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9044"><a href="https://www.suddencardiacarrestuk.org/shop/">Shop</a></li>
<li id="menu-item-9045" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9045"><a href="https://www.suddencardiacarrestuk.org/donate/">Donate</a></li>
<li id="menu-item-9046" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9046"><a href="https://www.suddencardiacarrestuk.org/about-us/">About</a></li>
<li id="menu-item-9047" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9047"><a href="https://www.suddencardiacarrestuk.org/contact/">Contact</a></li>
<li id="menu-item-9048" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9048"><a href="https://facebook.com/SuddenCardiacArrestUK"><i class="_mi dashicons dashicons-facebook" aria-hidden="true" style="font-size:1.8em;"></i></a></li>
<li id="menu-item-9049" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9049"><a href="https://twitter.com/WeAreSCAUK"><i class="_mi dashicons dashicons-twitter" aria-hidden="true" style="font-size:1.8em;"></i></a></li>
<li id="menu-item-9109" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9109"><a href="https://www.youtube.com/channel/UCJkb9cJprDJc8XokVMo8ENw"><i class="_mi dashicons dashicons-youtube" aria-hidden="true" style="font-size:1.8em;"></i></a></li>
<li id="menu-item-13021" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-13021"><a href="https://www.instagram.com/suddencardiacarrestuk/"><i class="_mi dashicons dashicons-instagram" aria-hidden="true" style="font-size:1.8em;"></i></a></li>
</ul></div> </div>
</nav>
Odd... can you try using a Layout Element to disable the navigation:
https://docs.generatepress.com/article/layout-element-overview/
That worked!
Thanks
Glad to hear that!