简体   繁体   中英

Remove short product description from woocommerce shop (archive) pages

For some reason in my shop pages the short description of each product has appeared beneath each product title. I have tried coding this out using:

body.page-id-7 .woocommerce-product-details__short-description { 
    display: none !important; 

However, I have found online that due to it being a woocommerce page this page ID I have used is not correct.

What is the correct way to remove the product short description from the main shop page?

If anyone knows how to do this please explain in simple terms! I am not the most knowledgeable with code so a step by step would be wonderful.

Please see my site to see what I am talking about :)

Thanks in advance!!

NB I still want the product description to be visible on the individual product pages.

If I understand correctly what you want to achieve, you must add this code to your CSS file:

body.archive .woocommerce-product-details__short-description { 
display: none;
}

It will looks like this:

screenshot

I added woocommerce/single-product/short-description.php to my theme from the woocommerce plugin then changed the code at the bottom to this:

<?php if ( is_product() ) : ?> 
  <div class="woocommerce-product-details__short-description">
    <?php echo $short_description; // WPCS: XSS ok. ?>
  </div>
<?php endif; ?>

I'd prefer to do it with a hook but I wasn't able to find a better solution.

is_product();

Is true if you are on the single product page.

You can get the file from https://github.com/woocommerce/woocommerce/blob/master/templates/single-product/short-description.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM