In the production of WordPress theme When I encountered this problem, and encountered a CSS style error, in fact very simple, the operation is as follows:
Add in functions.php in the topic:
Register_nav_menus (' Menu ' => __ (' menu ', ') ');
Post the navigation code in the subject navigation bar: <?php wp_nav_menu (' Id=navbar ');?>
However, CSS style errors have occurred:
The original output of this function is the following format:
Copy Code code as follows:
<div id= "MenuBar" >
<ul class= "Menus" >
<li class= "..." ><a href= "http://.../" >Home</a></li>
<li class= "..." ><a href= "http://.../" > menu item 1</a></li>
<li class= "..." ><a href= "http://.../" > menu item 2</a></li>
<li class= "..." ><a href= "http://.../" > menu item 3</a></li>
...
</ul>
</div>
It's OK, just filter it out:
Change the code to:
Copy Code code as follows:
<?php
Echo str_replace ("</ul></div>", "" ", Ereg_replace (" <div[^>]*><ul[^>]*> "," ", wp_nav_ Menu (Array (' theme_location ' => ' primary ', ' echo ' => false)));
?>