Add Class programmatically
-
Hello,
I need to add a class to my first level item, i’ve wrote this code without MaxMegaMenu and it works.
add_filter('nav_menu_css_class', 'add_color_classes', 1, 3); function add_color_classes($classes, $item, $args) { // Main nav only if ($args->theme_location == 'main-navigation') { // First level only if (intval($item->menu_item_parent) === 0) { $page_id = intval($item->object_id); $page_color = get_field('page_accent_color', $page_id)['label']; $classes[] = sanitize_html_class($page_color); } } return $classes; }But when I activate the plugin my class disappear.
Is there a specific filter/hook to make it works ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Add Class programmatically’ is closed to new replies.