Home › Forums › WoodMart support forum › Issue with megamenu and ajax
Issue with megamenu and ajax
- This topic has 7 replies, 2 voices, and was last updated 3 hours, 27 minutes ago by
grcp.
-
AuthorPosts
-
August 25, 2025 at 12:26 am #681811
grcpParticipantHi Support,
I’m using the megamenu along with Ajax for the shop.
I’ve noticed an issue: when I click on a category in the megamenu, the menu does not close automatically.Do you have any suggestions?
August 25, 2025 at 2:11 pm #681914
Hung PhamKeymasterHi grcp,
Thanks for reaching to us.
Unfortunately, there is no such an option.
Regards,
Hung PDAugust 25, 2025 at 2:17 pm #681918
grcpParticipantIs there really no other option? It doesn’t make sense that this is not supported. There are many themes out there that provide this functionality without causing issues with AJAX. Do I really have to disable AJAX – and make the website slower – just to make the Mega Menu work properly? This shouldn’t be the case.
Since there is already an option for AJAX loading in the shop, there should also be proper support for the Mega Menu. In other themes, when the user clicks on a category, the menu closes automatically, and the new category page is loaded. Otherwise, the user gets the impression that the site is “freezing,” because the Mega Menu remains open while the new page with the products has already loaded in the background.
Please take a look at this, as it directly affects the user experience and is very important for the website.
August 26, 2025 at 9:49 am #682042
Hung PhamKeymasterHi grcp,
Thank you for your feedback and for providing a detailed description of the situation. You are absolutely right — for users, it may look like the site is “freezing” when the menu remains open after clicking on a category.
At the moment, unfortunately, automatic closing of the Mega Menu when using AJAX loading is not supported. This is a limitation of the current logic.
However, we can provide you with a custom code snippet that will disable AJAX loading in this specific case and ensure that the menu closes correctly when navigating to a category:
Paste the code into Theme Settings > Custom JS > Global JS
add_filter('woodmart_ajax_links', function () { return '.wd-nav-product-cat a, .wd-page-wrapper .widget_product_categories a, .widget_layered_nav_filters a, .woocommerce-widget-layered-nav a, .filters-area:not(.custom-content) a, body.post-type-archive-product:not(.woocommerce-account) .woocommerce-pagination a, body.tax-product_cat:not(.woocommerce-account) .woocommerce-pagination a, .wd-shop-tools a:not([rel="v:url"]), .woodmart-woocommerce-layered-nav a, .woodmart-price-filter a, .wd-clear-filters a, .woodmart-woocommerce-sort-by a, .woocommerce-widget-layered-nav-list a, .wd-widget-stock-status a, .widget_nav_mega_menu a, .wd-products-shop-view a, .wd-products-per-page a, body[class*="tax-pa_"] .woocommerce-pagination a'; });
This way, the menu will close properly, and users will not have the impression that the page is “freezing.”
Regards,
Hung PDAugust 26, 2025 at 1:16 pm #682127
grcpParticipantHi Hung,
I’ve added the code, but it doesn’t seem to be working.
Is this code correct?August 26, 2025 at 5:47 pm #682239
grcpParticipantAny update ?
August 26, 2025 at 6:28 pm #682253
Hung PhamKeymasterHi grcp,
Sorry for typo.
Please remove above code from JS section and try to add these to the child theme functions.php file to fix this
Regards,
Hung PDAugust 26, 2025 at 6:33 pm #682257
grcpParticipantThank you mate ! Problem solved !
-
AuthorPosts
- You must be logged in to create new topics. Login / Register