• Resolved niftyanton

    (@niftyanton)


    I am working on a localhost child version of the new 2021 theme, and I haven’t been able to find a way to remove the “Open menu” button that appears when there are sub-menu items added to a primary menu item. I am not enquing the parent theme’s styles, so I assume the style.css of the 2021 theme hides this button by default?

    What I am wondering is how to get rid of this button completely. Is there a way/function I can use to override the default addition of this button when there are sub-menu items added to a menu?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Have you tried just hiding them with CSS?

    .primary-navigation .primary-menu-container > ul > .menu-item > a + .sub-menu-toggle {
    display: none;
    }

    Or are you looking for a walker function to physically remove the HTML?

    Oliver

    Further to my last message, this PHP should prevent the buttons from being displayed in the first place …

    function remove_twenty_twenty_one_add_sub_menu_toggle() {
    remove_filter('walker_nav_menu_start_el', 'twenty_twenty_one_add_sub_menu_toggle');
    }
    add_action('after_setup_theme', 'remove_twenty_twenty_one_add_sub_menu_toggle');

    Let me know if that works.

    Oliver

    Thread Starter niftyanton

    (@niftyanton)

    Thanks @domainsupport! I added that function and it removed the button.

    I know I could have hidden it with CSS, but I am partial to button’s removal just to avoid extraneous code (albeit a very small amount). Thanks for the help!

    Thread Starter niftyanton

    (@niftyanton)

    Hey @domainsupport, that makes sense and your solution worked. Thanks for looking into that for me.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘2021 Theme Adding Open Menu Button in Menu’ is closed to new replies.