未显示Bootstrap Navwalker

时间:2017-08-27 作者:Pain

我正在从头开始创建一个引导wordpress主题,我想使用wordpress nav walker类创建一个nav菜单,我遵循了上的文档GitHub 为了安装它,我在我的wordpress主题中添加了一个主菜单,我选择了菜单位置,但导航栏不会显示,我所拥有的只是位于中心的导航栏品牌。enter image description here 我的标题。php代码:

<div class="blog-masthead">
      <div class="container">
        <nav class="navbar navbar-default" role="navigation">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="<?php echo home_url(); ?>">
                <?php bloginfo(\'name\'); ?>
            </a>
    </div>

        <?php
            wp_nav_menu( array(
                \'menu\'              => \'primary\',
                \'theme_location\'    => \'primary\',
                \'depth\'             => 2,
                \'container\'         => \'div\',
                \'container_class\'   => \'collapse navbar-collapse\',
                \'container_id\'      => \'bs-example-navbar-collapse-1\',
                \'menu_class\'        => \'nav navbar-nav\',
                \'fallback_cb\'       => \'WP_Bootstrap_Navwalker::fallback\',
                \'walker\'            => new WP_Bootstrap_Navwalker())
            );
        ?>
    </div>
</nav>

      </div>
    </div>
功能。php

<?php
    require_once(\'wp-bootstrap-navwalker.php\');

    function wpb_theme_setup(){
        register_nav_menus( array(
        \'primary\' => __( \'Primary Menu\', \'wpbootstrap\' ),
) );
    }

    add_action(\'after_setup_theme\', \'wpb_theme_setup\');
有人能帮我解决这个问题吗?

1 个回复
SO网友:sakarya

我是这样用的。我从未遇到过任何问题。

引导程序3。带有wordpress下拉菜单的x导航。

<nav class="navbar navbar-default">
<div class="navbar-header">
    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
    </button>
    <a class="navbar-brand visible-xs" href="#">MENU</a>
</div>

<div class="collapse navbar-collapse" id="bs-navbar-collapse">
    <?php
        wp_nav_menu( array(
            \'theme_location\'    => \'primary\',
            \'depth\'             => 2,
            \'container\'         => \'\',
            \'menu_class\'        => \'nav navbar-nav\',
            \'fallback_cb\'       => \'wp_bootstrap_navwalker::fallback\',
            \'walker\'            => new wp_bootstrap_navwalker())
        );
    ?>
    <ul class="nav navbar-nav navbar-right">
        <?php if ( is_user_logged_in() ) { ?>
        <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user-plus" aria-hidden="true"></i> HESABIM <span class="caret"></span></a>
            <ul class="dropdown-menu">
                <?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
                <li><a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a></li>                             
                <?php endforeach; ?>
            </ul>
        </li>
        <?php } else { ?>
        <li><a href="<?php echo get_permalink( get_option(\'woocommerce_myaccount_page_id\') ); ?>" title="Üye Ol / Giriş Yap">Üye Ol / Giriş Yap</a></li>
        <?php } ?>
    </ul>
</div>

仅导航;

<div class="collapse navbar-collapse" id="bs-navbar-collapse">
<?php
    wp_nav_menu( array(
        \'theme_location\'    => \'primary\',
        \'depth\'             => 2,
        \'container\'         => \'\',
        \'menu_class\'        => \'nav navbar-nav\',
        \'fallback_cb\'       => \'wp_bootstrap_navwalker::fallback\',
        \'walker\'            => new wp_bootstrap_navwalker())
    );
?>
</div>

结束

相关推荐

如何为物化框架制作wp_NAV_Menu()的自定义Walker

我试图用materialize框架来创建WordPress主题,但我真的被导航栏部分弄糊涂了。我在互联网上搜索过,但没有找到任何东西,似乎没有人使用materialize。我发现的唯一一件事就是用nav\\u walker制作,就像在bootstrap中一样,但我不知道如何使用materialize。UPDATE:这是我的导航条形码; <div class=\"navbar\"> <nav> <div class