• I need to add an image before each taxonomy term to represent the term (ie, Beds might have a bed icon).

    I can use the Taxonomy Images plugin (https://www.ads-software.com/plugins/taxonomy-images/) to set the image per taxonomy, but I need some help figuring out where to display the images per taxonomy. Here is what their documentation says about display the taxonomy images:

    Display a single image representing the term archive
    The following filter will display the image associated with the term asked for in the query string of the url. This filter only works in views that naturally use templates like category.php, tag.php taxonomy.php and all of their derivatives. Please read about template hierarchy for more information about these templates. The simplest use of this filter looks like:
    
    print apply_filters( 'taxonomy-images-queried-term-image', '' );
    This code will generate and print an image tag. It's output can be modifed by passig an optional third parameter to apply filters. This parameter is an array and the following keys may be set:
    
    after (string) - Text to append to the image's HTML.
    
    attr (array) - Key/value pairs representing the attributes of the img tag. Available options include: alt, class, src and title. This array will be passed as the fourth parameter to WordPress core function wp_get_attachment_image() without modification.
    
    before (string) - Text to prepend to the image's HTML.
    
    image_size (string) - May be any image size registered with WordPress. If no image size is specified, 'thumbnail' will be used as a default value. In the event that an unregistered size is specified, this filter will return an empty string.
    
    Here's an example of what a fully customized version of this filter might look like:
    
    print apply_filters( 'taxonomy-images-queried-term-image', '', array(
        'after' => '</div>'
        'attr' => array(
            'alt'   => 'Custom alternative text',
            'class' => 'my-class-list bunnies turtles',
            'src'   => 'this-is-where-the-image-lives.png',
            'title' => 'Custom Title',
            ),
        'before' => '<div id="my-custom-div">',
        'image_size' => 'medium',
        ) );

    Could you help me understand how to display these images prior to the WP Listing taxonomy terms (for features specifically, if it matters).

    https://www.ads-software.com/plugins/wp-listings/

Viewing 1 replies (of 1 total)
  • Thread Starter Angie Meeker

    (@ameeker)

    echo '<h5>Tagged Features</h5><ul class="tagged-features">';
    				$terms = apply_filters( 'taxonomy-images-list-the-terms', '', array(
    				'taxonomy' => 'features',
    				'image_size'   => 'detail',
    			) );
    
    			foreach( (array) $terms as $term){
    				echo $term;
    			};
    
    				echo '</ul><!-- .tagged-features -->';

    This works to display the images of features with a taxonomy image (it doesn’t display the feature if there is no taxonomy image, but for us, I think that will be ok since they should all have one). I would still like to know how to display the taxonomy term still (above only displays the taxonomy image).

Viewing 1 replies (of 1 total)
  • The topic ‘Adding taxonomy images before taxonomy term’ is closed to new replies.