WordPress.org

Support

Support » Plugins and Hacks » WooCommerce » [Resolved] Category thumbnail

[Resolved] Category thumbnail

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author James Koster

    @jameskoster

    Please try the following in your functions.php file.

    add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 );
    function woocommerce_category_image() {
    	if ( is_product_category() ){
    	    global $wp_query;
    	    $cat = $wp_query->get_queried_object();
    	    $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
    	    $image = wp_get_attachment_url( $thumbnail_id );
    	    if ( $image ) {
    		    echo '<img src="' . $image . '" alt="" />';
    		}
    	}
    }

    Thanks so much, this code help me,
    how can i put this(cat-image) on single-product.php?
    this code isnt work in single product….

    Thanks

    Katie

    @greenpeadesign

    Thanks, this is just what I was looking for.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Category thumbnail’ is closed to new replies.
Skip to toolbar