Hi,
I’m trying to create a menu where each menu item has an associated image… the idea is on mouse over the image will show off to the side…
In ACF I’ve added a custom image field to ‘menu items’ and added an image in the wordpress menu system.
I’m having a problem retrieving this data using the BricksExtras WP Menu extra loop.
when I try displaying the ACF field as an attribute {acf_menupicture} its always empty.
I’ve tried using this snippet
function add_acf_to_menu_items($items, $args) {
foreach ($items as $item) {
// Get the ACF image field
$image = get_field('menupicture', $item);
if ($image) {
// Add the image URL as a custom attribute
$item->acf_image = $image['url'];
}
}
return $items;
}
add_filter('wp_nav_menu_objects', 'add_acf_to_menu_items', 10, 2);
But it returns nothing.
It seems that the menu items are different from a regular Wordpress query result and don’t retrieve any ACF data from its items.
Anyone know how to get this to work?