I have created a colour picker field with ACF which shows on every category page and allows the end user to assign a colour to each category. This is working well but I would like the categories on my main navigation to also be assigned the colour given on the colour picker field.
I have a walker class and the bit I think I need to implement this on would be the bit of code bellow. So, I guess I need to add an inline style of "colour:" if the menu item is taxonomy with the variable that holds the category colour from the colour picker field. Something like the bellow:
$item_output = $args->before;
if( $item->object == 'category' ) {
$post_categories = get_the_category();
foreach( $post_categories as $post_category ) {
$category_color = get_field( 'category_color', $post_category);
$item_output .= '<a style="color:' . $category_color . ';"'. $attributes .'>';
}
} else {
$item_output .= '<a'. $attributes .'>';
}
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= ( $args->has_children ) ? '<i class="fa fa-angle-down"></i></a>' : '</a>';
$item_output .= $args->after;
The code above is assigning the same colour to all category menu items on the main menu. I'm trying now to figure out how to assign the colour chosen on each category page colour picker field to each category menu item.
$category_color
? If you inspect the CSS, is it being overriden by anything?