Display Taxonomy Image on single.php

I’m using Taxonomy Images, and I can’t figure out how to display a category’s associated image on a single.php. Essentailly, when a user is viewing a post that utilizes the single.php template, it should display the post’s category’s image. Right now, it just doesn’t display anything.

This is the code that I’m using:

<?php 
    $image_id = apply_filters( "taxonomy-images-queried-term-image-id", 0 );
    if ( ! empty( $image_id )):
    print apply_filters( "taxonomy-images-queried-term-image", "",  array(
        "image_size" => "large"
    ) );
    endif;
?>

2 Answers
2

I used this little trick to obtain the taxonomy image given the ID of the term:

<?php
    $images = get_option('taxonomy_image_plugin');
    $img_url = wp_get_attachment_url( $images[$term_id] ); 
?> 

Leave a Comment