navigation - Can I now add a class in the anchor of my menu item with Wordpress 5.4?

I am using the following code in my functions.php file:function add_menuclass($ulclass) {return preg_replace('<

I am using the following code in my functions.php file:

function add_menuclass($ulclass) {
return preg_replace('/<a title="All"/', '<a title="All" class="addition-of-class-name"', $ulclass, 1);
}
add_filter('wp_nav_menu','add_menuclass');

So, as you can see, I am checking for a menu item anchor and then adding a class in the anchor that comes after the menu item snippet that I have configured in my Wordpress site.

<li class="class-added-by-wp-menu-item-already">
   <a class="CAN-I-ADD-A-CLASS-WITH-THE-NEW-FIELD-HERE-NOW?">
   </a>
</li>

/

Can I now do this with the new functionalities in Wordpress 5.4 / to be precise:

wp_nav_menu_item_custom_fields
wp_nav_menu_item_custom_fields_customize_template

Or did I misread?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744609150a4583657.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信