Mobile menu parent link on xstore theme with elementor

This topic has 12 replies, 3 voices, and was last updated 2 weeks ago ago by Luca Rossi

  • Avatar: 2347281
    2347281
    Participant
    March 6, 2025 at 18:37

    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.

    Please, contact administrator
    for this information.
    11 Answers
    Avatar: 2347281
    2347281
    Participant
    March 7, 2025 at 09:27

    and one more: in lightbox apears some line “data-e-action-hash=”

    Files is visible for topic creator and
    support staff only.
    Avatar: Justin
    Luca Rossi
    Support staff
    March 9, 2025 at 15:25

    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!

    Avatar: Hassan
    Hassan
    Participant
    March 27, 2025 at 13:04

    Hello,

    Did this solution work?

    I have the same problem with parent link on mobile menu.

    Thanks

    Avatar: 2347281
    2347281
    Participant
    March 27, 2025 at 13:09

    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

    Avatar: Hassan
    Hassan
    Participant
    March 27, 2025 at 13:39

    Did you put this in the themes function.php file?

    thanks

    Avatar: 2347281
    2347281
    Participant
    March 27, 2025 at 14:03

    yep

    Avatar: Hassan
    Hassan
    Participant
    March 27, 2025 at 14:14

    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.

    Avatar: 2347281
    2347281
    Participant
    March 27, 2025 at 14:17

    i’m on elementor too, should work, try on new device, it may be browser cache left

    Avatar: Justin
    Luca Rossi
    Support staff
    March 27, 2025 at 18:06

    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

    Avatar: 2347281
    2347281
    Participant
    March 28, 2025 at 12:40

    @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

    Avatar: Justin
    Luca Rossi
    Support staff
    March 28, 2025 at 13:39

    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

  • Viewing 12 results - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.Log in/Sign up

Helpful Topics

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.