Archived topic
Remove Nav Class
8 replies · Started by Niklas on September 17, 2018
Hi,
i would like to use the mega menu. To make it work i need to remove the "main-navigation" class of the nav can you please tell me how to solve this?
<nav itemtype="https://schema.org/SiteNavigationElement" itemscope="itemscope" id="site-navigation" class="main-navigation grid-container grid-parent"></nav>
Thank you and best regards,
Niklas
Hi there,
are you using a Mega Menu plugin?
Hi David,
thanks for your reply.
Yes, i am using the "megamenu" plugin. The support of that plugin told me to remove that class to solve my problem.
I am not sure how to handle it.
Little confused, i would assume the megamenu plugin should replace the GP Navigation entirely.
What is the problem? Is the megamenu not displaying? Can you share a link to the site?
Hi David,
That is the link of the site. I am using the woocommerce plugin as well and would like to put certain products into the mega menu. This is not working. But is does work, when you remove the class “main-navigation” class out of the nav element.
BR
Niklas
As per the WP topic here:
https://wordpress.org/support/topic/woocommerce-shortcodes-in-the-grid-layout/#post-10695125
You would need to add this function. There are alternatives to using a child theme such as adding the code to the Code Snippets plugin:
Hi David,
thank you for the support but that doesn't work.
If I paste the code into the snippets plugin it says:
The code snippet you are trying to save produced a fatal error on line 14:
Cannot redeclare mega_menu_remove_main_navigation_class() (previously declared in /www/htdocs/w0135547/xxx/wp-content/plugins/megamenu-edit/megamenu-edit.php:13)
Is there another way to remove that specific class?
Regards,
Niklas
Hi David,
I could fix it by using that css code:
.mega-menu-primary .main-navigation ul ul {
height: auto;
background: transparent;
position: relative;
left: auto;
width: auto;
box-shadow: none;
pointer-events: auto;
opacity: 1;
}
Thank you & regards,
Niklas
If you need to remove that class (not recommended), you can do this:
add_filter( 'generate_navigation_class', function( $classes ) {
$classes = array_diff( $classes, array( 'main-navigation' ) );
return $classes;
} );