我想在wp_nav_menu里面添加一个变量,我不知道怎么做,请帮帮我吧!以下是代码片段:
wp_nav_menu(array(
'menu' => 'Main Menu',
'theme_location' => 'Main Menu',
'container' => null,
'container_class' => '',
'menu_id' => 'header-menu',
'menu_class' => '',
'before' => '<span class="text1">',
'after' => '</span><span class="text2"><a href="">' . the_title($post->ID) . '</a></span>',
));
请帮助我!
答案 0 :(得分:2)
wp_nav_menu
添加一些额外值的方法。
wp_nav_menu(array(
'MyItem' => 'My Value', // <--new item
'MyotherItem' => 'My Other Value', // <--other new item
'menu' => 'Main Menu',
'theme_location' => 'Main Menu',
'container' => null,
'container_class' => '',
'menu_id' => 'header-menu',
'menu_class' => '',
'before' => '<span class="text1">',
'after' => '</span><span class="text2"><a href="">' . the_title($post->ID) . '</a></span>',
));
答案 1 :(得分:0)
看看this tutorial。它很可能回答你的问题和更多
答案 2 :(得分:0)
试试这个会添加网址
wp_nav_menu( array( 'theme_location' => 'header-menu','menu_class' => 'drop', 'container' => 'nav', 'link_before' => '<span></span>') );
如果你想这样就是url
wp_nav_menu( array( 'theme_location' => 'header-menu','menu_class' => 'drop', 'container' => 'nav', 'link_before' => '<span>', 'link_after' => '</span>') );