• Resolved miruru

    (@miruru)


    When using the option: 'having_images'=>false, this does not return all the terms that has an image associated with it. It only displays the terms that has posts with the images. Is this the normal behaviour?

    For example, I have 20 terms, each with an image, 10 of these terms has a number of posts. I want to be able to display all 20 terms in a given taxonomy whether or not they have any posts. Is this possible?

Viewing 6 replies - 1 through 6 (of 6 total)
  • hide_empty = 0

    Plugin Contributor Michael Fields

    (@mfields)

    Setting having_images to false will just return unfiltered output of get_terms(). Please try Diogo15’s suggestion of setting the hide_empty argument of get_terms(). This would look something like this:

    $terms = apply_filters( 'taxonomy-images-get-terms', '', array(
    	'taxonmoy'  => 'taxonomy-name',
    	'term_args' => array(
    		'hide_empty' => 0,
    		),
    	) );
    Thread Starter miruru

    (@miruru)

    Thank you Diogo15 and Michael, using hide_empty worked.

    I’m trying to use this and it’s not working for me. Here’s my code:

    <?php $terms = apply_filters( 'taxonomy-images-get-terms', '', array(
        'taxonomy' => 'tool',
        'term_args' => array(
    		'hide_empty' => 0,
    		),
        ) );
    
    		if ( ! empty( $terms ) ) {
        	print '<ul class="taxonomy">';
        	foreach( (array) $terms as $term ) {
            	print '<li><a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'detail' ) . esc_html( $term->name ) . '</a></li>';
        	}
        	print '</ul>';
    	}
    ?>

    It displays the image and term name fine if there is an image, but i still want the term name to display if there is no image associated with it.

    Thanks for the plugin!

    Plugin Contributor Michael Fields

    (@mfields)

    You’ll need to set “having_images” to false in the filter’s array.

    Thanks, sorry to bother you with that. I tried having_images earlier and I now realize that I was typing it I kept typing quotes around false when I shouldn’t have. I guess that’s what happens when you’re working way too late ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Taxonomy Images] Having_images set to false not working’ is closed to new replies.