如何在wordpress中的wp_nav_menu中添加一个类

时间:2015-09-04 09:51:21

标签: wordpress

我是WordPress的新手,我不知道如何在wp_nav_menu中添加任何课程,以便有人帮助我。

<?php wp_nav_menu(array('theme_location' => 'primary',
'menu'=>'Menu','container'=>'','items_wrap'=>'<ul  class="nav navbar-nav">%3$s</ul>')); ?>

1 个答案:

答案 0 :(得分:0)

这可能会有所帮助。在wp-includes / nav-menu-template.php中有一个函数wp_nav_menu($ args = array()),其中菜单是creted。在函数中有$ deafults数组,它就像这样:

$defaults = array( 
    'menu' => '', 'container' => 'div', 
    'container_class' => '', 
    'container_id' => '', 
    'menu_class' => 'menu', 
    'menu_id' => '',
    'echo' => true, 
    'fallback_cb' => 'wp_page_menu',
    'before' => '', 'after' => '', 
    'link_before' => '', 
    'link_after' => '', 
    'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    'depth' => 0,
    'walker' => '', 
    'theme_location' => '' );

更改&#39; menu_class&#39; =&GT; &#39;菜单&#39;到&#39; menu_class&#39; =&GT; &#39;菜单my_class&#39;