如何合并两个在wordpress中单独管理的菜单以在前端主题中显示为一个? [英] How to merge two menu managed separately in wordpress for displaying as one in front end theme?

查看:19
本文介绍了如何合并两个在wordpress中单独管理的菜单以在前端主题中显示为一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个已经建立在 wp 上的网站开发 wp 主题,并且有非常大的菜单,在 wp 管理中分为两个菜单.

I am working on a wp theme for a site which is already built on wp, and having very large menu which is divided into two menu in wp admin.

我想在单个 UL 中合并主题中的这两个菜单.目前它在不同的 div 容器和 ul li 中生成两个菜单,并且正在打破样式&js 应用在它上面.

I want to merge this two menu in theme in single UL. Currently it generates two menu in different div container and ul li, and is breaking the styles & js applied on it.

如何将这两个菜单合并为单个容器中的单个 ul li?

How can i merge this two menu into single ul li in single container?

推荐答案

ok,所以如果你正在使用 wp_nav_menu()

ok, so if you are using the wp_nav_menu()

尝试使用类似的东西

<ul id="MyMenu">
  <?php wp_nav_menu( array('menu' => 'FirstMenu', 'items_wrap' => '%3$s' ) ); ?>
  <?php wp_nav_menu( array('menu' => 'SecondMenu', 'items_wrap' => '%3$s' ) ); ?>
</ul>

使用 items_wrap 将从每个菜单中删除 ul,因此将菜单封装在一个已经定义的 ul 标签中,wp_nav_menu 将只吐出 li 标签.

using the items_wrap will remove the ul from each menu, so encapsulate the menu in an already defined ul tag, the wp_nav_menu will spit out just li tags.

参见去除 ul 换行:http://codex.wordpress.org/Function_Reference/wp_nav_menu

See Removing the ul wrap: http://codex.wordpress.org/Function_Reference/wp_nav_menu

M

这篇关于如何合并两个在wordpress中单独管理的菜单以在前端主题中显示为一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆