Not sure how to click edit on that last post as I posted the wrong code…
I am using the below with Image Array option selected:
// loop
foreach( $items as &$item ) {
// vars
$icon = get_field('menu_image', $item);
// append icon
if( $icon ) {
$item->title = ' <img src="' . $icon['url'] . '" class="menu-image" alt="' . $icon['alt'] . '"><br>' .$item->title;
}
}
// return
return $items;
Sorry, I marked the answer as solved because I thought I had it for a sec, but I still cant get it to work
Below is the code:
// loop
foreach( $items as &$item ) {
// vars
$icon = get_field('menu_image', $item);
// append icon
if( $icon ) {
$item->title = ' <img src="' . $url['url'] . '" class="menu-image" alt="' . $image['alt'] . '"><br>' .$item->title;
}
}
// return
return $items;
I have changed my field to output Image Array and am using the above code but it now wont display the image url or the alt tags….. Not sure what I am missing
Oh my gosh!! I feel so silly that I totally forgot I did that. Yep, you are right and thank you that helped solve my question!