Support » Plugin: Taxonomy Images » Get image of product tag

  • Hi,

    i need to get product tag for woocommerce product, i write a function but now i see all tags and not just product tagged in.

    This i my code, what i’m wrong ?

    $terms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy' => 'product_tag', ) );
    
            if ( ! empty( $terms ) ) {
                
                print '<div class="container">';
                
                foreach ( (array) $terms as $term) {
                    
                $url = get_term_link ($term->slug, 'product_tag');
                
    
                print '<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">';
                print '<div class="card">';
                print '<div class="card-img-top"><a href="'.$url.'">' . wp_get_attachment_image( $term->image_id, 'medium' ) . '</a></div>';
                print '<div class="card-body">';
    			
    			$tags = get_the_terms( $id, 'product_tag' );
    			
    			foreach ($tags as $tag) {
    			
    			
                print "<h5 class='card-title'><a class='btn btn-primary' href='{$url}'>{$tag->name}</a></h5>";
    			
    			}
    			
                print '</div>';
                print '</div>';
                print '</div>';
            }
                print '</div>';
                
            }
        }
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Get image of product tag’ is closed to new replies.