I wish to add a class to a specific item of my primary menu. I’m using this:
function hideMenuItem ( $atts, $item, $args ) {
$commerce = get_field('ecommerce', 'option');
if (!$commerce){
$menu_items = array(566,567, 363, 364 );
if (in_array($item->ID, $menu_items)) {
$atts['class'] = 'hidden';
}
return $atts;
}else{
$menu_items = array(566,567);
if (in_array($item->ID, $menu_items)) {
$atts['class'] = 'visible';
}
return $atts;
}
}
add_filter( 'nav_menu_link_attributes', 'hideMenuItem', 10, 3 );
It’s working only on the li link but I wish to apply it on the li.