WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Category thumbnail (4 posts)

  1. Hung Pham
    Member
    Posted 1 year ago #

    In each category, I have uploaded an image. But how to show it on web page please?

    Thanks.

    http://wordpress.org/extend/plugins/woocommerce/

  2. jameskoster
    Member
    Plugin Author

    Posted 1 year ago #

    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="" />';
    		}
    	}
    }
  3. adrianovarlotta
    Member
    Posted 10 months ago #

    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

  4. Katie
    Member
    Posted 9 months ago #

    Thanks, this is just what I was looking for.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic