dongling2038 2017-10-27 14:15
浏览 69
已采纳

使用underscores.me在WordPress中不显示菜单

I'm having trouble getting the "Menu" or "Navigation Menu" to appear in the header.

The code in header.php

<header>
 <?php if ( !is_front_page() ) : ?>
            <nav role="navigation" class="site-navigation main-navigation">
                <h1 class="assistive-text"><?php _e( 'Menu', 'underscoresme' ); ?></h1>
                <div class="assistive-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'underscoresme' ); ?>"><?php _e( 'Skip to content', 'underscoresme' ); ?></a></div>
                <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
            </nav><!-- .site-navigation .main-navigation -->
        <?php endif; ?>
</header>

Menu configuration in the dashboard

enter image description here

Live customization

enter image description here

It simply doesn't want to appear. There is no <nav> when inspecting in dev tools. I didn't changed anything in functions.php or any other file that contains PHP code that is used to make the theme work. I want to use Bootstrap's navigation menu.

karnopedia.com is the site.

  • 写回答

1条回答 默认 最新

  • dtbam62840 2017-10-27 15:06
    关注

    Remove the exclamation point in your !is_front_page() check. Your code works but is not displaying on front page because of the check.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?