Good evening, there is a website using the XStore theme and Elementor. Question: Is it possible to enable links for parent categories in the mobile menu? Right now, only the sub-menu opens, and it’s not possible to access the main category.
This topic has 12 replies, 3 voices, and was last updated 2 weeks ago ago by Luca Rossi
Good evening, there is a website using the XStore theme and Elementor. Question: Is it possible to enable links for parent categories in the mobile menu? Right now, only the sub-menu opens, and it’s not possible to access the main category.
and one more: in lightbox apears some line “data-e-action-hash=”
Dear @2347281,
Please try adding this custom code under functions.php file locates in your child theme:
add_action('wp_footer', 'n2t_wp_footer');
function n2t_wp_footer() {
?>
<script>
jQuery((document).on('click touchend', '.etheme-elementor-nav-menu.vertical li a.item-link.etheme-elementor-nav-menu-item.etheme-elementor-nav-menu-item-parent', function (e){
window.location.href = jQuery(this).attr('href');
});
jQuery(document).on('click touchend', '.etheme-elementor-nav-menu.vertical li a.item-link.etheme-elementor-nav-menu-item.etheme-elementor-nav-menu-item-parent span.etheme-elementor-nav-menu-item-arrow', function (e){
var parent = jQuery(this).parent().parent();
console.log(parent);
jQuery(parent).next('.nav-sublist-dropdown').slideToggle();
return false;
});)
</script>
<?php
}
and one more: in lightbox apears some line “data-e-action-hash=”
Please provide the product URL.
Thank you!
Hello,
Did this solution work?
I have the same problem with parent link on mobile menu.
Thanks
no,
i wrote my solution:
function xstore_modify_menu_items($items) {
foreach ($items as &$item) {
if (in_array('menu-item-has-children', $item->classes)) {
$item->title = '<span class="has-submenu">' . $item->title . '</span>';
}
}
return $items;
}
add_filter('wp_nav_menu_objects', 'xstore_modify_menu_items');
function enqueue_custom_mobile_menu_script() {
wp_enqueue_script(
'custom-mobile-menu',
get_stylesheet_directory_uri() . '/js/mobile-menu.js',
array('jquery'),
filemtime(get_stylesheet_directory() . '/js/mobile-menu.js'),
true
);
}
add_action('wp_enqueue_scripts', 'enqueue_custom_mobile_menu_script');
now toggle opens dropdown, o category click opens category
Did you put this in the themes function.php file?
thanks
yep
Thanks for the solution, but it didn’t work for me.
I added it to the functions.php file and cleared the cache, but the links are still not clickable.
I’ve switched to using the Elementor header instead of the native XStore theme header. Maybe that is why the code didnt work.
i’m on elementor too, should work, try on new device, it may be browser cache left
Dear @Hassan,
We kindly request you to create a separate support ticket and provide the URL of your website along with the administrator account details.
Our team will be happy to assist you in debugging the custom codes.
Thanks for sharing a solution @2347281!
Best regards,
8Theme Team
@Hassan , I completely forgot and missed this: with the code we’re adding to functions.php, we’re also including a .js script. Please create a file named mobile-menu.js with the following code:
document.addEventListener("DOMContentLoaded", function () {
const menuItems = document.querySelectorAll(".menu-item-has-children > a, .has-submenu");
menuItems.forEach((menuItem) => {
menuItem.addEventListener("click", function (e) {
const parentItem = this.closest(".menu-item-has-children");
if (!parentItem.classList.contains("submenu-open")) {
e.preventDefault();
parentItem.classList.add("submenu-open");
} else {
window.location.href = this.closest("a").href;
}
});
});
});
and place it in the theme folder so that the path is:
xstore-child/js/mobile-menu.js
Thanks for sharing @2347281!
@Hassan you can also use this plugin to insert the custom codes: https://wordpress.org/plugins/code-snippets/.
Best Regards,
8Theme’s Team
You must be logged in to reply to this topic.Log in/Sign up