我必须将html菜单转换为WordPress菜单,但它无法正常工作。我实现代码就像打击一样:
HTML代码
<!-- start navbar -->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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 site_url();?>">WpF <span>BGness</span></a>
<!-- <a class="navbar-brand" href="index.html"><img src="img/logo.png" alt="logo"></a> -->
</div>
<div id="navbar" class="navbar-collapse collapse navbar_area">
<!-- <ul class="nav navbar-nav navbar-right custom_nav">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="contact.html">Contact Us</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Link one</a></li>
<li><a href="#">Link Two</a></li>
<li><a href="#">Link Three</a></li>
</ul>
</li>
<li><a href="page.html">Page</a></li>
<li><a href="blog-archive.html">Blog</a></li>
</ul> -->
<?php
$args=array('theme_location'=>'primary');
wp_nav_menu($args);
?>
</div><!--/.nav-collapse -->
</div>
</nav>
<!-- End navbar -->
注册菜单 我在 functions.php 中注册了一个菜单。
add_theme_support('menus');
function awsome_menu_add()
{
register_nav_menus( array(
'primary' => __( 'primary menu'),
'secondary' => __( 'Header Menu' ),
'responsive'=> __( 'Responsive Menu'),
'footer' => __( 'Footer Menu'),
) );
}
add_action('after_setup_theme','awsome_menu_add');
输出:
答案 0 :(得分:0)
使用主题位置的小写更改代码。
这
$args=array('theme_location'=>'Primary');
到
$args=array('theme_location'=>'primary');