Wordpress Theme -> Custom Nav Menu
I'm pretty new at creating Wordpress themes, and I need some help with the navigation menu. The format for the navigation bar needs to be something like this:
<ul id="nav">
<li class="top"><a href="#home" class="top_link"><span>Home</span></a></li>
<li class="top"><a href="#page1" class="top_link"><span>My Page</span></a>
<ul class="sub">
<li><a href="#page1_1" >My Page _ 1</a></li>
<li><a href="#page1_2" >My Page _ 2</a></li>
<li><a href="#page1_3" >My Page _ 3</a></li>
<li><a href="#page1_4" >My Page _ 4</a>
<ul>
<li><a href="#page1_4_1">My Page _ 4 _ 1</a></li>
<li><a href="#page1_4_2">My Page _ 4 _ 2</a></li>
<li><a href="#page1_4_3">My Page _ 4 _ 3</a></li>
</ul>
</li>
</ul>开发者_如何学编程;
</li>
<li class="top"><a href="#page2" class="top_link"><span>2nd Page</span></a>
<ul class="sub">
<li><a href="#page2_1">2nd Page _ 1</a></li>
<li><a href="#page2_2">2nd Page _ 2</a></li>
<li><a href="#page2_3">2nd Page _ 3</a></li>
</ul>
</li>
<li class="top"><a href="#apage" class="top_link"><span>Another Page</span></a></li>
<li class="top"><a href="#xpage" class="top_link"><span>xPage</span></a></li>
</ul>
And I'm sure you can tell how everything the pages should go.
You can try NAVT plugin for doing this. Its pretty configurable.
You should follow the Wordpress documentation http://codex.wordpress.org/Function_Reference/wp_nav_menu#Example.
In your case, to add a SPAN inside the link, just do the following:
<?php wp_nav_menu( array(
......
......
'link_before'=>'<span>',
'link_after'=>'</span>'
)); ?>
But, if you apply the above code, you will have the SPAN inside all of the LINKs, even for sub-levels. You can easily fix the SPANs for the sub-levels by CSS. Otherwise, to have more controls, you can see the Wordpress Menu-Walker system: http://codex.wordpress.org/Function_Reference/wp_nav_menu#Example.
精彩评论