• In the parent functions.php
    is this code:

    function woocommerce_template_loop_product_thumbnail() {
    	printf( '<span class="et_shop_image">%1$s<span class="et_overlay"></span></span>',
    		woocommerce_get_product_thumbnail()
    	);
    }

    I don’t want to mess with my parent files so have managed to create this code and make it work when placed in the functions.php of my child theme.

    function woocommerce_template_loop_product_thumbnail() {
    	printf( '<span class="et_shop_image">%1$s<span class="et_overlay"><span class="shop_caption"><h6>%2$s</h6></span><p class="info">READ MORE</p></span></span>',
    		woocommerce_get_product_thumbnail(),
    		( get_post_thumbnail_caption() )
    	);
    }

    The problem:
    The child theme code only works if I remove the noted parent theme code. When I keep both pieces of code it breaks the site.
    Note: I’m on a localhost so can’t share a link.

    Question:
    Is there a way to make my child theme code work without having to mess with my parent theme file?

    Thanks for your help

Viewing 8 replies - 1 through 8 (of 8 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Check where this is being called from:

    woocommerce_template_loop_product_thumbnail

    Then see if you can rename your Child Theme function and call that instead.

    Do you see what I mean?

    Thread Starter chickspirit

    (@chickspirit)

    Hmm…
    Sadly I’m not well versed in understanding how files work. I just kind of stumbled upon that solution from scouring the www.

    Am I looking for something in my parent functions.php file or am I looking for another file that is being called?

    What does the code look like to rename the function in my child theme?

    While I wait for help I’ll try and figure out what you mean with another scouring of the www. ??

    Thread Starter chickspirit

    (@chickspirit)

    Is this what I’m looking for?

    // WooCommerce
    
    global $pagenow;
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' )
    	add_action( 'init', 'et_divi_woocommerce_image_dimensions', 1 );

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Yes looking through your parent functions.php file to see where woocommerce_template_loop_product_thumbnail is being called.

    What does the code look like to rename the function in my child theme?

    That is hopefully what you’re going to find when you look through the parent functions.php file.

    What theme are you using?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Is this what I’m looking for?

    I don’t think so because it has to be an exact match of ‘woocommerce_template_loop_product_thumbnail

    Thread Starter chickspirit

    (@chickspirit)

    I did a search for ‘woocommerce_template_loop_product_thumbnail’ in my parent functions.php and it only exists in that one place I posted above.

    I’m wondering if I’m supposed to create this using hooks based on skimming this:

    Uggh! Maybe not? My code doesn’t have an action just a printf.

    In my mind it seems like it should be easy to change what you see once you find what code is creating the visuals but I guess not. This definitely isn’t CSS lol

    I appreciate your help.

    Thread Starter chickspirit

    (@chickspirit)

    Oh I’m using the Divi theme with a woocommerce plugin

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I think your theme’s vendors would be best to take this forward: https://www.elegantthemes.com/contact.html

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Make Adjustment to functions.php in child theme’ is closed to new replies.