Support » Plugin: Taxonomy Images » How can i get the image from taxonomy ID?

Viewing 1 replies (of 1 total)
  • HI There, I had the same question and I wrote my own code so I thought I would share for others.

    This is to obtain the images for my custom taxonomy “service” and print them out within my custom get_terms() loop.

    $taximages = get_option( 'taxonomy_image_plugin' );
    
    $services = get_terms(array(
        'taxonomy' => 'service',
        'hide_empty' => false,
    ));
    
    foreach($services as $service) {
      $link = get_term_link(intval($service->term_id),'service');
      echo "<h2><a href=\"{$link}\">{$service->name}</a></h2>";
      $taximageid = $taximages[intval($service->term_id)];
      echo wp_get_attachment_image ($taximageid, 'medium');
    }

    Hope it helps 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘How can i get the image from taxonomy ID?’ is closed to new replies.