what i want to achieved is this
<div class="someclass"> // in place of <ul>
<a class="item">Page Title</a>
<a class="item">Page Title</a>
<a class="item">Page Title</a>
.
.
.
</div>
This is the patter which is used by semantic UI for horizontal menu
I have achieved this much
<div class="ui secondary menu">
<a href="http://localhost/wordpress/lbs/services/">Services</a>
<a href="http://localhost/wordpress/lbs/portfolio/">Portfolio</a>
<a href="http://localhost/wordpress/lbs/shop/">Shop</a>
</div>
by using code
<div class="ui secondary menu">
<?php
$menuParameters = array(
'menu' => 'top-menu',
'container' => false,
'echo' => false,
'items_wrap' => '%3$s',
'depth' => 0,
);
echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
?>
</div>
But i want to add
class="item"
to
<a href="http://localhost/wordpress/lbs/services/">Services</a>
Please guide..
thankx
Finally I able to do this..
<div id="menu1" class="ui secondary menu">
<?php
$menuParameters = array(
'menu' => 'top-menu',
'menu_class' => 'item',
'container' => false,
'echo' => false,
'items_wrap' => '%3$s',
'depth' => 0,
);
echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
?>
</div>
<script>
jQuery( "#menu1 a" ).addClass( "item" );
</script>
答案 0 :(得分:1)
您可以使用'menu_class'=> 'item'
示例:强>
<div class="ui secondary menu">
<?php
$menuParameters = array(
'menu' => 'top-menu',
'menu_class' => 'item',
'container' => false,
'echo' => false,
'items_wrap' => '%3$s',
'depth' => 0,
);
echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
?>
</div>
答案 1 :(得分:1)
阅读关于函数wp_nav_menu
的codex,你使用它错了,做这样的事情:
echo strip_tags(wp_nav_menu(
'items_wrap' => '<div id="%1$s" class="%2$s">%3$s</div>',
'menu_class' => 'myclass ui',
'echo' => false,
), '<a>');
在wordpress admin&gt; appereance&gt;菜单,您可以为每个链接定义类。只需确保您已在屏幕选项中打开它。
但您也可以执行this之类的操作来添加课程。
答案 2 :(得分:1)
谢谢你感谢你的回答,不幸的是,它给了我这个输出的工作量
代码使用
<div class="ui secondary menu">
<?php
$menuParameters = array(
'menu' => 'test-menu',
'menu_class' => 'item',
'container' => false,
'echo' => false,
'items_wrap' => '%3$s',
'depth' => 0,
);
echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
?>
</div>
中没有输出任何课程
<div class="ui secondary menu">
<a href="http://localhost/wordpress/lbs/">Home</a>
</div>