I have this simple snippet in my header displaying the site's Main Menu:
<?php wp_nav_menu( array(
'theme_location' => 'main-menu',
'container'=> false ) );
?>
The menu displays the site's pages. Each page has a custom field added with Advanced Custom Fields called text_color. It's a color picker that let's me choose which color the menu item should have when hovering on it. I would like to have this field in the settings for the page itself, and not as a field added to the menu settings of Wordpress.
The hovering effect is created with a data attribute called data-hover. I then listen for mouseover and mouseleave events through JavaScript on each menu item, changing the text color of the menu item upon hovering, to the color code that's in the data-hover.
Since each menu item is connected to a page, I would like to be able to reach the page loop for each menu item, adding this data-hover to each anchor link in the menu item. Is this possible?