嗨我试图让mainmenu工作,但我想我做错了,这里是代码:
我正在使用bootstrap并将其链接为:
<link href="<?php bloginfo('stylesheet_directory'); ?>/assets/css/bootstrap.min.css" rel="stylesheet">
任何人都知道如何做到这一点?
<!-- HEADER
===========================================-->
<header class="site-header" role="banner">
<!-- NAVBAR
===========================================-->
<div class="navbar-wrapper">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
<?php
wp_nav_menu( array(
'menu' => 'primary',
'theme_location' => 'primary',
'container' => 'div',
'container_class' => 'navbar-collapse collapse',
'container_id' => 'navbar',
'menu_class' => 'nav navbar-nav'
) );
?>
</div>
</div>
</div>
</header>
更新版本
答案 0 :(得分:0)
Wordpress菜单将实例化一个菜单对象 - 你真的得到了菜单的html,但这应该是:
<nav id="site-navigation" class="main-navigation mobile-navigation">
<!-- <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php //esc_html_e( 'Primary Menu', 'eldon' ); ?></button> -->
<?php
wp_nav_menu( array(
'theme_location' => 'menu-1',
'menu_id' => 'primary-menu',
) );
?>
</nav><!-- #site-navigation -->
应该在安装的后端设置菜单,这将引用标题模板中的这一点。
使用WordPress约定查看https://github.com/WordPress/WordPress/tree/master/wp-content/themes以获取header.php模板的示例。请始终参考食典委 - 您需要确保不要破坏主题!
https://codex.wordpress.org/Theme_Development
您可以做的最好的事情是从wordpress.org下载WordPress的新副本,然后重试。您不应该更改这些模板,但如果您这样做,请确保您正确地执行此操作:)