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?