1
votes

I'm trying to display a description of a WooCommerce single product, but the instead of displaying the correct description, the loop starts over again displaying the image, price, add to cart etc.

I've tried to find the answer for long time with no avail. I have used the WooCommerce template scripts and edit them; the_excerpt() will work but not the_content().

This is the template file I am currently using: https://github.com/woocommerce/woocommerce/blob/master/templates/single-product/tabs/description.php

the_content() is now the problem. Could it be my query or something? I have different way to query my products from index.php, but the archive-product.php is having the same as WooCommerce query has. Could this be the cause, even if it's in the single-product.php the problem?

I use this for the front-page.php:s product loop:

<div class="col-9 main-products">
    <?php echo do_shortcode('[products paginate="true" limit="30" orderby="popularity"]'); ?>
</div>

content-single-product.php, archive-product.php and single-product.php are the same as the WooCommerce template has.

It should display the description instead of looping over again. There are no error messages.

I've also used a different theme and the products display correctly, so the problem isn't in any plugins I am using.

1
woocommerce single product page hook for description is add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 ); where are you attempting to display this the excerptBrad Holmes
@BradHolmes I have it like this <div class="summary entry-summary"> <?php /** * Hook: woocommerce_single_product_summary. * * hooks ... */ do_action( 'woocommerce_single_product_summary' ); ?> </div>Timppa
And it is in the content-single-product.php fileTimppa

1 Answers

1
votes
echo wpautop(get_the_content());

This code fixed the problem! Replace the_content() with the code above in the description.php. I found out the solution from here: https://wordpress.stackexchange.com/questions/298383/post-content-being-duplicated-by-the-content by KreigD's answer.