Skip to content

Total Theme: Add Templates to submenu Items

Add the class „megamenu-template-1“ to the submenu item to replace its content. Add this code to the functions.php

// Override the menu item with the 'megamenu-template-1' class with a dynamic template
add_filter( 'walker_nav_menu_start_el', function( $output, $item, $depth, $args ) {
	
    if ( isset( $item->classes ) && is_array( $item->classes ) && in_array( 'megamenu-template-1', $item->classes, true ) ) {
        return do_shortcode( '<div class="wpex-no-renaming">[wpex_template id="24011"]</div>' );
    }
    return $output;
}, 50, 4 );

An den Anfang scrollen