Support » Plugin: Taxonomy Images » Get image from term id

  • I think the documentation misses a very important and simple use case. I got a term id and taxonomy id and i want the associated image. Simple as that, no template restriction, no filters, nothing. Is that even possible?

Viewing 1 replies (of 1 total)
  • Try the following:

    // Set your defined term ID
    $tem_id = 39; // (an integer)
    
    // Get the array of Term ID/Image ID pairs
    $taxonomy_images = get_option( 'taxonomy_image_plugin' );
    
    $attachment_id = $taxonomy_images[$tem_id]; // Image ID
    $image = wp_get_attachment_image( $attachment_id ); // Image
    $term = get_term( $tem_id ); // The WP_Term object
    $link = get_term_link( $tem_id ); // The term link
    
    // Output example
    echo '<a>'.$image.'<span>'.$term->name.'</span></a>';

    It should work.

Viewing 1 replies (of 1 total)
  • The topic ‘Get image from term id’ is closed to new replies.