WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Category images not showing in product category widget (8 posts)

  1. Jon Henwood
    Member
    Posted 1 year ago #

    Hi

    How do I add the product category image to the woocommerce products category sidebar widget. Please let me know the php and the line it needs to go on.

    Thanks

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

  2. invaderB
    Member
    Posted 1 year ago #

    I'm curious on this as well, if anyone could shed some light?

  3. morgsta
    Member
    Posted 1 year ago #

    I can't get any images to show on category widget or category product page. The Categories are set up with a thumbnail but nothing appears

  4. paulmp
    Member
    Posted 1 year ago #

    I'd really like a resolution for this as well. I can't get them to show up in the widget.

  5. owlonline
    Member
    Posted 10 months ago #

    I'd like to see this functionality as well. Any clues?

  6. documentninja
    Member
    Posted 10 months ago #

    I am trying to figure this out too. Can anyone help??

  7. edmacfly
    Member
    Posted 9 months ago #

    Sorry to revive an oldish thread, but has anyone managed to solve this? Is there a plugin that would do this job? TIA

  8. danielbaker
    Member
    Posted 9 months ago #

    I have found a way to solve this issue - though it means editing a core file. I am hoping to create a hook/filter to do the same soon.

    Basically look for:
    plugins/woocommerce/classes/walkers/class-product-cat-list-walker.php

    Then on line 62:

    function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {
    
    	    $thumbnail_id = get_woocommerce_term_meta( $object->term_id, 'thumbnail_id', true ); // get category thumbnail id
    	    $image = wp_get_attachment_url( $thumbnail_id ); // get image and convert to var
    
    		$output .= '<li class="cat-item cat-item-' . $object->term_id;
    
    		if ( $args['current_category'] == $object->term_id )
    			$output .= ' current-cat';
    
    		if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $object->term_id, $args['current_category_ancestors'] ) )
    			$output .= ' current-cat-parent';
    
    		$output .=  '"><a href="' . get_term_link( (int) $object->term_id, 'product_cat' ) . '">' . __( $object->name, 'woocommerce' ) . '<img src="' . $image . '" alt="" /></a>'; // insert category image into link
    
    		if ( $args['show_count'] )
    			$output .= ' <span class="count">(' . $object->count . ')</span>';
    
    	}

    Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic