• Resolved lotteroelofs

    (@lotteroelofs)


    Hi there,

    Hope someone can help.

    I wish to add my category picture to my product overview page. How can I do this?
    Example of a page where I wish to place is
    here

    Thanks very much in advance!

    Lotte

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hey,

    This looks like something that you’re going to need to use a child theme with.

    If you’re unfamiliar with using a child theme, then you can read about that and download from here:
    https://www.kadencethemes.com/child-themes/

    I just tested this function that I found from here:
    https://docs.woocommerce.com/document/woocommerce-display-category-image-on-category-archive/

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

    And it works great on my site! You’ll want to place that into the functions.php file of your child theme.

    The image that is output will be set in Products> Categories and then the “Thumbnail.”

    Let me know if this works for you!

    -Kevin

    Thread Starter lotteroelofs

    (@lotteroelofs)

    Kevin you are a star! Will test this this weekend (first time for me working on a child theme, so exciting!) I’ll let you know if it works.

    Lots of thanks for now!

    Thread Starter lotteroelofs

    (@lotteroelofs)

    Thanks Kevin,

    Making the child them worked, but I can’t seem to find the right location in my function.php to paste the code in. I’ve tried all option. Any suggestions?

    thanks again!

    It should work if you place it in the bottom of the functions.php. Are you using FTP to make changes to the file?

    -Kevin

    Thread Starter lotteroelofs

    (@lotteroelofs)

    Hi Kevin,

    Yes, I am using Filezilla to make the changes.
    I’ve placed the code after the </html> tag.
    This is the result

    Kind regards,

    Lotte

    There shouldn’t be anything like that in your functions.php file if you downloaded it directly from the link that I sent you. (Kadence Themes Child Themes)

    It sounds to me like you’re either placing it into the parent theme functions.php file, or an incorrect file altogether.

    If you are placing it in your functions.php, can you share what else is in that file?

    Thanks,
    Kevin

    Thread Starter lotteroelofs

    (@lotteroelofs)

    Hi Kevin,

    There is nothing else in the 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 ''; 		} 	} }

    Kind regards,

    Lotte

    Strange. I’m a bit confused as to what’s happening so I’ll send this thread to the theme author so he can take a look. it’s probably something simple that I’m overlooking.

    -Kevin

    Are you starting the functions file with<?php

    Thread Starter lotteroelofs

    (@lotteroelofs)

    Dear Kevin and @britner,

    Thank you so much! It is now working like a charm.

    Many thanks for your help and wishing you a lovely weekend!

    Kindest regards,

    Lotte

    Thread Starter lotteroelofs

    (@lotteroelofs)

    Closing the thread! ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Category picture on product overview page’ is closed to new replies.