WordPress 主题 ->自定义导航菜单
我在创建 Wordpress 主题方面还很陌生,我需要一些导航菜单方面的帮助。导航栏的格式需要是这样的:
<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>
我相信您可以告诉页面的所有内容应该如何进行。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试 NAVT 插件来执行此操作。它非常可配置。
You can try NAVT plugin for doing this. Its pretty configurable.
您应该遵循 WordPress 文档 http://codex.wordpress.org/Function_Reference/wp_nav_menu#Example。
在您的情况下,要在链接内添加 SPAN,只需执行以下操作:
但是,如果您应用上述代码,您将在所有链接内拥有 SPAN,即使对于子级别也是如此。您可以通过 CSS 轻松修复子级别的 SPAN。否则,要获得更多控件,您可以查看 Wordpress Menu-Walker 系统:http://codex。 wordpress.org/Function_Reference/wp_nav_menu#Example。
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:
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.