skip to Main Content

Sometimes when I open a single product page the wrong product image pops up in the main image and the first image of the carousel. This is not every time but randomly. Also the wrong image is not everytime the same.

This is the link:
http://www.asdbmx.nl/wp-content/uploads/2019/10/troy-lee-designs-d2-delta-silver-blue-0.jpg

The good one looks like this:
Good version

The wrong one looks like this:Wrong version

Does somebody know what causes the problem and how to solve it?
It is really frustrating that sometimes it will work and sometimes it won’t

I’m using the latest version of woocommerce and the theme i use is Avada (Also the latest version).

I hope somebody can help me.

Thanks in advance.

This is the code of the single-product.php
I hope you can help me out

Code:

    <?php
/**
 * The Template for displaying all single products
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see         https://docs.woocommerce.com/document/template-structure/
 * @package     WooCommerce/Templates
 * @version     1.6.4
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

get_header( 'shop' ); ?>

    <?php
        /**
         * woocommerce_before_main_content hook.
         *
         * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
         * @hooked woocommerce_breadcrumb - 20
         */
        do_action( 'woocommerce_before_main_content' );
    ?>

        <?php while ( have_posts() ) : ?>
            <?php the_post(); ?>

            <?php wc_get_template_part( 'content', 'single-product' ); ?>

        <?php endwhile; // end of the loop. ?>

    <?php
        /**
         * woocommerce_after_main_content hook.
         *
         * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
         */
        do_action( 'woocommerce_after_main_content' );
    ?>

    <?php
        /**
         * woocommerce_sidebar hook.
         *
         * @hooked woocommerce_get_sidebar - 10
         */
        do_action( 'woocommerce_sidebar' );
    ?>

<?php
get_footer( 'shop' );

/* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for your help again!

    I’m gonna try it with the new “debug helmets” And the theme part I know.. but back then I didn’t...

    Nowadays I use Divi. It’s faster and no extra plugins needed. And much easier to add css and javascript.

    Thanks for your help again!


  2. I’ve had a look at your website, and has I can’t see the backend this is purely hypothetical… Wild guess:

    For me it seems like 2 loop messing up each one another. I would say that on your product page (maybe?), you’re not resetting the post data wp_reset_postdata() or not resetting the query wp_reset_query() properly upon finishing the loop. But without any code that’s just a wild guess.

    It’s probably just a stupid mistake that is quickly fixable.

    You should consider posting the page source code if you need any help (If you’re using woocomerce the problem is probably on the product page).

    https://developer.wordpress.org/reference/functions/wp_reset_postdata/
    https://developer.wordpress.org/reference/functions/wp_reset_query/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search