Home Forums Front-end Issues Display image-field in custom menu Reply To: Display image-field in custom menu

  • @bknightly i cant say how to use it with ID,
    but i can show you how to use a size, when you do it with array (3 option beside id and url)

    $items = wp_get_nav_menu_items('menu_name'); //replace menu_name with menu-name, menu-id, menu-slug (menu-location is not valid!)
    foreach((array) $items as $key => $item) {
    	$taxonomy = $item->object;
    	$term_id = $item->object_id;
    	$url = $item->url;
    	$title = $item->title;
    	$image_url= get_field('icoon', $taxonomy._.$term_id); //replace "icoon" with the fieldname you give to the image
    	echo '<li><a href="'.$url.'" title="'.$title.'"><img src="'.$image_url[sizes][large].'" /></a></li>'; //replace large with size you wish

    hope that help nevertheless

    just if someone is interested, i use this for build a taxonomy menu with images:

    // to build a menu with image and name from a Taxonomy i use this (inside my archive-CPT.php):
    //this values you need to adjust: 
    //my_taxonomy => slug of taxonomy (3x)
    //my_taxonomy_image => name of imagefield at taxonomy page (1x)
    //teaser_thumbnail => image size
    $terms = get_terms("my_taxonomy", array(
        'hide_empty' => 0
    $count = count($terms);
    if ( $count > 0 ){
        foreach ( $terms as $term ) {
        $permalink = get_term_link( $term->slug , 'my_taxonomy');
        	$output .=  '<div class="taxonomy_menu_item"><a href='.$permalink.' titel="'.$term->name.'">';
            $my_taxonomy_teaserimage = get_field('my_taxonomy_image', 'my_taxonomy_'.$term->term_id);
            $size_taxonomy_teaserimage = 'teaser_thumbnail';
    	$taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage ];
    	$width_taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage . '-width' ];
    	$height_taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage . '-height' ];
    	$output .=  '<img alt="'. $term->description .'" src="'. $taxonomy_teaserimage .'" width="'.$width_taxonomy_teaserimage.'" height="'.$height_taxonomy_teaserimage.'" />';
    	$output .=   '<h3>'.$term->name.'</h3>';
    	$output .=  '</a></div>';
    echo $output;