网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

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

GG网络技术分享 2025-03-18 16:12 4


问题描述:

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.

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~

功能建议

我无法将“菜单”或“导航菜单”显示在标题中。</ p >

header.php </ code> </ p>

 &lt; header&gt; 

&lt;?php if(!is_front_page( )):?&gt;

&lt; nav role =“navigation”class =“site-navigation main-navigation”&gt;

&lt; h1 class =“assistive-text”&gt;&lt;?php _e(\'Menu \',\'underscoresme\'); ?&gt;&lt; / h1&gt;

&lt; div class =“assistive-text skip-link”&gt;&lt; a href =“#content”title =“&lt;?php esc_attr_e(\'Skip to content\',\' underscoresme\');?&gt;“&gt;&lt;?php _e(\'Skip to content\',\'underscoresme\'); ?&gt;&lt; / a&gt;&lt; / div&gt;

&lt;?php wp_nav_menu(array(\'theme_location\'=&gt;\'primary\')); ?&gt;

&lt; / nav&gt;&lt;! - .site-navigation .main-navigation - &gt;

&lt;?php endif; ?&gt;

&lt; / header&gt;

</ code> </ pre>

仪表板中的菜单配置</ p>

</ p>

实时自定义</ p>

</ p>

它根本不想出现。 在dev工具中检查时,没有&lt; nav&gt; </ code>。 我没有在 functions.php </ code>或任何其他包含用于使主题工作的 PHP </ code>代码的文件中进行任何更改。 我想使用Bootstrap的导航菜单。</ p>

karnopedia.com 是该网站。 </ p>

</ div>

网友观点:

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

标签:

提交需求或反馈

Demand feedback