wordpress主题制作时,常常会在不同的位置调用不同的菜单,使用下面的这个代码,再加上CSS给菜单做新的样式,可满足wordpress模板制作时对菜单调用的所有需求。
wp_nav_menu( array(
‘theme_location’ => ‘’,//导航别名
‘menu’ => ‘’, //期望显示的菜单
‘container’ => ‘div’, //容器标签
‘container_class’ => ‘’,//ul父节点class值
‘container_id’ => ‘’, //ul父节点id值
‘menu_class’ => ‘menu’, //ul节点class值
‘menu_id’ => ‘’, //ul节点id值
‘echo’ => true,//是否输出菜单,默认为真
‘fallback_cb’ => ‘wp_page_menu’, //菜单不存在时,返回默认菜单,设为false则不返回
‘before’ => ‘’, //链接前文本
‘after’ => ‘’, //链接后文本
‘link_before’ => ‘’, //链接文本前
‘link_after’ => ‘’,//链接文本后
‘items_wrap’ => ‘%3$s’, //如何包装列表
‘depth’ => 0, //菜单深度,默认0
‘walker’ => ‘’ //自定义walker
) );
原文
https://www.wowsoho.com/news/1844.html