4
将自定义沃克添加到小部件中创建的菜单
我知道如何将Walker添加到由主题创建的自定义菜单(primary在此示例中命名的菜单),但是如何定位使用默认wordpress自定义菜单小部件在小部件中创建的菜单呢? if ( has_nav_menu( 'primary' ) ) { $args = array( 'menu' => 'main-menu', 'menu_id' => 'main-menu', 'theme_location' => 'primary', 'depth' => 0, 'container' => false, 'menu_class' => 'nav', 'walker' => new Myprefix_Walker_Nav_Menu(), 'echo' => 0 ); $nav = wp_nav_menu( $args ); }