Change Arrow Icons in New Navigation Block

  • Hi GP/B team.

    How can I change the “gb-submenu-toggle-icon” to another .svg in the new navigation block?

    Thanks already for help.

    Christian

  • Hi Christian,

    I don’t think there’s a built-in way for this, unfortunately.

  • Okay. Is there a way to solve this with code in the functions.php, similar to original navigation with the generate_svg_icon_element?

  • Yes, you can use the general WP filter nav_menu_item_title, GB uses the same filter to add the default dropdown arrow:

    add_filter( 'nav_menu_item_title', function( $title, $menu_item ) {
    
        if ( false === strpos( $title, 'gb-submenu-toggle-icon' ) ) {
            return $title;
        }
    
        $old_svg = '/<svg class="gb-submenu-toggle-icon.*?<\/svg>/s';
    
        $new_svg = '<svg class="gb-submenu-toggle-icon" viewBox="0 0 24 24" aria-hidden="true" width="1em" height="1em" fill="currentColor">
            <path d="M7 10l5 5 5-5z"/>
        </svg>';
    
        return preg_replace( $old_svg, $new_svg, $title );
    
    }, 20, 2 );

    Just update the SVG code for $new_svg.

  • Thanks, that’s great. 😉

    Is this also working with the navigation arrows in the new carousel block?

  • No, that’s different, it’s not a menu item.

  • Ok. Thanks again for your help! 😉

  • No Problem 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.