• Resolved babrees

    (@babrees)


    Woocommerce has a category image and this should display beside the
    archive’s description when you add the code below. This works perfectly in twenty twelve theme but it simply will not work in a genesis theme. According to WooCommerce Support, “it seems like this is related to your theme and the way it integrates with WooCommerce.”

    Do you have any ideas on how I can get this to work please? I am running Genesis v.2 with html5 enabled, child theme is custom.

    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 '';
    }
    }
    }

    http://wordpress.org/plugins/genesis-connect-woocommerce/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Contributor studiograsshopper

    (@studiograsshopper)

    This line doesn’t make sense:

    if ( $image ) {
    echo '';
    }

    If there’s an image, it displays an empty string, so replace the above snippet with this:

    if ( $image ) {
    echo $image;
    }
    Thread Starter babrees

    (@babrees)

    Thanks, but that doesn’t work either. There are slight variations on the code, and this is the last one that I tried, which doesn’t work either 🙁 Am desperate now…

    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="" />';
    		}
    	}
    }
    Plugin Contributor studiograsshopper

    (@studiograsshopper)

    I can get this to work with your original code (plus modification I mentioned in my first reply), so I’m not sure what to suggest.

    You can see it here on my install: http://dev.studiograsshopper.ch/woocommerce/shop/product-category/instruments/

    The guitar image you see is the product category image for my “Guitars” product category.

    Can you post a link to the page where the image is supposed to show?

    Also, in the category edit screen, is your category image displayed alongside the cat name?

    Thread Starter babrees

    (@babrees)

    http://www.funkthis.com/product-category/mens-t-shirt/

    I confirm that in the category edit the image does show, although not alongside the cat name it shows at the thumbnail field which is below the display type.

    I also confirm that the image shows when I switch to the twentytwelve theme, adding the last code I posted above, the image does show.
    Switch to my Genesis theme and it does not show.

    I also tried a it with a clean Genesis Sample child theme and the image still does not show.

    I have also turned off all other plugins and still it does not show.
    ARGH!

    Plugin Contributor studiograsshopper

    (@studiograsshopper)

    I may be barking up the wrong tree, but bear in mind that the category image for a child category will only show on the parentcategory page – providing that the WooC settings are set to show subcategories.

    So, just to explain what I mean, if you look at the page on my site that I linked to above, “Guitars” is a subcategory of “Instruments” and therefore the “Guitars” category image will ONLY show on the “Instruments” page. In other words, the Guitars category image never appears on the Guitars category page. Makes sense?

    Thread Starter babrees

    (@babrees)

    Hi. The problem is the image DOES show next to the description on the category archives when I have twenty-twelve activated.

    I will activate twenty-twelve so that you can see it.

    http://www.funkthis.com/product-category/mens-t-shirt/

    But when I reactivate a genesis theme the image (in this case a man in a t-shirt) disappears.

    Plugin Contributor studiograsshopper

    (@studiograsshopper)

    What version of WooC and GCW are you using?

    Also, are you using any custom GCW templates?

    Thread Starter babrees

    (@babrees)

    WooCommerce v.2.0.13
    GCW v. 0.9.5

    Not sure what you mean about custom GCW templates.

    ahh, (lightbulb!) I am using a custom category.php – could that be a problem?

    This is my category.php…

    <?php
    // Remove content within categories
    remove_action('genesis_entry_content', 'genesis_do_post_content');
    
    require_once(PARENT_DIR . '/index.php');
    ?>

    Thread Starter babrees

    (@babrees)

    hmm, no it wasn’t that. I just deleted the category.php from my theme and reactivated it, but the image still didn’t show.

    Plugin Contributor studiograsshopper

    (@studiograsshopper)

    Can you post the exact code you are using now to display the cat image?

    Frankly, I’m not sure how much further we’ll be able to go with sorting this out, without having access to your install.

    Thread Starter babrees

    (@babrees)

    This is the code, as stated it works perfectly in twenty-twelve, just not in genesis. If you don’t mind having a look at my install I am happy to give you access.

    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="" />';
    		}
    	}
    }

    At the moment I am almost at the stage of giving up on Genesis and using another theme, although I really don’t want to.

    Plugin Contributor studiograsshopper

    (@studiograsshopper)

    You can send an admin login to me at ade at studiograsshopper.ch

    Plugin Contributor studiograsshopper

    (@studiograsshopper)

    Ok! Finally worked out what’s going on… (I’ve fixed your site, but I’m posted the fix below for anyone else who may be having the same issue.)

    This is a TEMPORARY fix which will be dealt with properly when I do the next GCW update.

    1. Using FTP (preferably) or the Dashboard Plugin Editor (please avoid this), open up the genesis-connect-woocommerce/lib/template-loader.php file.

    2. In template-loader.php scroll down to the genesiswooc_content_product() function (line 234)

    3. Within this function, find this code:

    <?php if ( is_tax() && get_query_var( 'paged' ) == 0 ) : ?>
    		<?php echo '<div class="term-description">' . wpautop( wptexturize( term_description() ) ) . '</div>'; ?>
    	<?php elseif ( ! is_search() && get_query_var( 'paged' ) == 0 && ! empty( $shop_page ) && is_object( $shop_page ) ) : ?>
    		<?php echo '<div class="page-description">' . apply_filters( 'the_content', $shop_page->post_content ) . '</div>'; ?>
    	<?php endif; ?>

    and replace it with this:

    <?php do_action('woocommerce_archive_description'); ?>

    That’s it! Category images should now show on their own product archive page.

    Plugin Contributor studiograsshopper

    (@studiograsshopper)

    Marking this one as resolved.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Genesis prevents Category image from showing’ is closed to new replies.