我正在研究WordPress主题。在主导航菜单中,我必须使用以下代码在菜单项上应用Bootstrap4样式(从here).
register_nav_menus( array(
\'menu-1\' => esc_html__( \'Primary\', \'theme-textdomain\' ),
) );
// Now, you can display the menu in your theme via below PHP code addition in the header.php file of your theme.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="<?php esc_html_e( \'Toggle Navigation\', \'theme-textdomain\' ); ?>">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar-content">
<?php
wp_nav_menu( array(
\'theme_location\' => \'menu-1\',
\'menu_id\' => \'primary-menu\',
\'container\' => false,
\'depth\' => 2,
\'menu_class\' => \'navbar-nav ml-auto\',
\'walker\' => new Bootstrap_NavWalker(),
\'fallback_cb\' => \'Bootstrap_NavWalker::fallback\',
) );
?>
</div>
</nav>
如果我不使用导航行走器,编辑快捷方式将可见,并适用于导航菜单。
但是,当我使用导航助行器时,按钮会消失。
我尝试在customiser中添加此代码
$wp_customize->selective_refresh->add_partial(\'primarymenu\', array(
\'selector\' => \'#site-navigation\',
\'render_callback\' => \'asensio_customize_partial_primarymenu\',
));
这没有效果。