简体   繁体   English

WordPress:在wp_nav_menu输出中添加更多代码

[英]Wordpress: Adding further code to wp_nav_menu output

I'm currently using a custom menu within Wordpress and I'm wanting the code that is outputted to include a span inside the link tag. 我目前在Wordpress中使用自定义菜单,并且希望输出的代码在链接标记中包含一个跨度。

The result I am looking for is: 我正在寻找的结果是:

<ul class="quicklinks">
    <li class="custom-class"><a href="#">Link 1<span class="arrow"></span></a></li>
    <li class="custom-class"><a href="#">Link 2<span class="arrow"></span></a></li>
    <li class="custom-class"><a href="#">Link 3<span class="arrow"></span></a></li>
</ul>

I'm currently using the following: 我目前正在使用以下内容:

<?php wp_nav_menu(array(
    'menu' => 'Quicklinks 1',
    'theme_location' => 'quicklinks-home',
    'fallback_cb' => 'wp_page_menu',
    'items_wrap' => '<ul class="quicklink">%3$s</ul>'
)); ?>

Which results in: 结果是:

<ul class="quicklinks">
    <li class="custom-class"><a href="#">Link 1</a></li>
    <li class="custom-class"><a href="#">Link 2</a></li>
    <li class="custom-class"><a href="#">Link 3</a></li>
</ul>

I've tried to alter the items_wrap part of the code above. 我试图更改上面代码的items_wrap部分。 However, I'm getting mixed results and it removes the ability to add in a custom CSS class. 但是,我得到的结果好坏参半,它删除了添加自定义CSS类的功能。 I don't think I'm a million miles away... just need a little help to get over the line. 我不认为我在百万英里之外……只需要一点帮助就能越过终点线。

Any help would be gratefully received! 任何帮助将不胜感激!

You should read the wp_nav_menu reference at 您应该在以下位置阅读wp_nav_menu参考

http://codex.wordpress.org/Function_Reference/wp_nav_menu . http://codex.wordpress.org/Function_Reference/wp_nav_menu

See, the link_after parameter. 请参阅link_after参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM