Wordpress - Getting a taxonomy's thumbnail url
The images where setted by woocommerce,
In case someone needs, this is how I did it
$thumb_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true );
$term_img = wp_get_attachment_url( $thumb_id );
Taxonomies don't by default have thumbnail images. Without knowing how those are set I can't say exactly how to get the thumbnails, but as for "what am I doing wrong?" get_post_thumbnail_id
accepts a post ID or lacking that assumes the current post in the Loop. You are passing it a term_id
, which isn't going to work. You can see that in the source:
32 function get_post_thumbnail_id( $post_id = null ) {
33 $post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
34 return get_post_meta( $post_id, '_thumbnail_id', true );
35 }
I suppose, if the term_id
happens to match a post ID you'd get something but it isn't going to be what you want or expect.