I have a wp_list_pages based menu and i want to add a class to a menu element with a ACF field. Any idea how i could do this? I know how to filter by ACF fields:
'meta_key' => 'nav_sichtbar',
'meta_value' => 'sichtbar',
but i think what i need is a if-else function within this.
I made it with a “Walker”
class Walker_ACF extends Walker_Page {
function start_el(&$output, $page, $depth, $args, $current_page) {
// get ACf field
$acfclass = get_field('nav_verlinken', $page->ID);
$output .= $indent . '<li class="' . $css_class . ' ' . $acfclass . "_verlinkt" . '"><a>ID) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>';
}
}
wanted to use “walker_nav_menu_start_el” but couldn’t get it running.