How to get value of simple_field through a taxonomy?

I’m trying to get the image in a simple_field trough a taxonomy but I can’t se it, if I take a var_dump I get the title and other stuff like the link the description, but not the image… Does anyone have an idé of how to access this image/simple_field?

I’m using wordpress and php,

$tt = get_terms('product_type', array());

foreach ($tt as $term) :
print $term->name.  ": ";
$q = new WP_Query(array(
    'post_type' => 'ep-produkter',
    'post_status' => 'publish',
    'posts_per_page' => -1, // = all of 'em
    'tax_query' => array(
        'taxonomy' => $term->taxonomy,
        'terms' => array( $term->term_id ),
        'field' => 'term_id',
    ),
));

$first = true;
foreach ($q->posts as $item) :
    var_dump($item);
    print '<a href="'.get_permalink($item->ID).'">'
      .$item->post_title.'</a>';
      //here i want to echo the img
endforeach;
endforeach;

Related posts

1 comment

  1. you can use following function in your for loop to print the featured image of post :

    //here i want to echo the img
    echo get_the_post_thumbnail( $item->ID, 'thumbnail' );
    

    or else, you can get the image url and display the image using img tag like this :

    //here i want to echo the img
    $url = wp_get_attachment_url( get_post_thumbnail_id($item->ID) );
    echo '<img src="$url" alt="" />';
    

Comments are closed.