In this guide we will enable/make the root menu items in the main menu clickable.


Files Modified:

/wp-content/themes/rhythm/js/all.js



all.js

Remove or comment out line 380 in the activate_classic_menu_item() function.

You can see the function below:

function activate_classic_menu_item(item) {

    var mnThisLi;

    if ($(".main-nav").hasClass("mobile-on")) {
        mnThisLi = $(item).closest("li");

        if (mnThisLi.hasClass("js-opened")) {
            mnThisLi.find(".mn-sub:first").slideUp(function(){
                mnThisLi.removeClass("js-opened");
                mnThisLi.find(".mn-has-sub").find(".mn-angle-icon").removeClass("fa-angle-up").addClass("fa-angle-down");
            });
        }
        else {
            $(item).find(".mn-angle-icon").removeClass("fa-angle-down").addClass("fa-angle-up");
            mnThisLi.addClass("js-opened");
            mnThisLi.find(".mn-sub:first").slideDown();
        }

        return false;
    }
    return false; // remove or comment this line
}

Remove or comment the second line from the bottom of the snippet in all.js to enable the root main menu links.



Application in Child Theme

To apply this change to the child theme, create a copy of the modified all.js file inside the child theme directory, and add the following line of code into functions.php:

function custom_all_js() {
    wp_register_script( 'all', get_stylesheet_directory_uri().'/js/all.js',array('jquery'),"100",true);
}
add_action('wp_enqueue_scripts', 'custom_all_js');