WooCommerce: Show Product Description @ Home / Loop

If you want to show the “short description” field on the products that are on your homepage or in the loop, here’s the PHP code to add to your functions.php

Show Product Description Inside the Loop – PHP


/**
 * @snippet       Show product short description on the homepage WooCommerce
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=257
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 2.4.7
 */

add_action( 'woocommerce_after_shop_loop_item_title', 'bbloomer_ins_woocommerce_product_excerpt', 35, 2);

function bbloomer_ins_woocommerce_product_excerpt() {
     if ( is_home() ) {
     echo '<span class="excerpt">';
     the_excerpt();
     echo '</span>';
     }
}

Show Product Description Outside the Loop – PHP


/**
 * @snippet       Show product short description on the homepage WooCommerce
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=257
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 2.4.7
 */

echo apply_filters( 'the_content', get_post_field('post_content', $product_id) );

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

26 thoughts on “WooCommerce: Show Product Description @ Home / Loop

  1. Hi. Great work.

    Is it possible to display the short description for all user roles except for just one specific? Thanks in advance.

    1. Hi Marcial, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. Is there a way to display the short description on mouse over shop image? Thank you.

    1. Hello Tania, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

    2. Thank you! I kind of thought that as I haven’t been able to find how to do it anywhere. Thank you for contributing so much to helping understanding woocommerce, very much appreciated.

  3. How can I show only the short description? This is showing long description if no short description is given for the product, when instead I want nothing to be shown if there is no short description.

    Thanks!

    1. Hey Joe, thanks for your comment! “the_excerpt” should only echo the short description – is that the one you’re using?

  4. Hello Rodolfo,

    I tried adding exact the same code snippet from above but my problem is, that the function is there but it’s not being displayed properly. So there is the text but it’s not visible. First I have to change the style (e.g. the font-size to 13px) in style.css to make it visible. Why is that? Is it normal that I have to edit also the style.css to make a custom action added to a hook visible?

    Thanks in advance!

    1. Hey Martina, thanks for your comment! Yes, this probably depends on your custom theme – that’s why I added a class inside the HTML so that you can customize it as you wish ๐Ÿ™‚

  5. Hi Rodolfo,
    I was trying to do something similar as your article.
    What I would need to do is to add a short description for each product in the checkout page. I have done tons of research and this is the best I have come up with:

    $post_data->post_excerpt );
    return $other_data;
    }
    ?>

    The issue is that with this code I can only display the number 1, but I can’t see my product decription or attributes…
    Can you help me with that? I have tried everything I can…
    Thank you

    1. Paloma, thanks so much for your feedback! Yes, this is possible – but unfortunately this is custom work and I cannot provide this solution on the blog right now. If you would like to get a quote, feel free to go here. Thank you! R

  6. Thank you for the article. Can you please help me with a problem. How I can remove short description from the Archive page for the variable product only?

    1. Hi Sourav, you can simply wrap the function contents within this conditional check:

      function …. {
      if( $product->is_type( ‘simple’ ) ){
      // function content
      }
      }

  7. Thank you….

  8. Hi Redolfo,
    Thanks so much for this! I’ve been searching for this solution and yours is the only one that is understandable to someone NOT too confident with coding! I’ve added the code and can now see the short description here: http://journey2health.co.za/index.php/shop/
    I would like to make the description even shorter – perhaps only about 20 words. Any advice on how to do that would be GREATLY appreciated!

    1. Thank you Charine, much appreciated ๐Ÿ™‚ I see your website is broken so I can’t really help with the second question. However take a look at this article I wrote: Woocommerce: How to shorten product titles because that’s very similar to what you’re looking for! Hope this helps. R

  9. hello I’m Not able to get the content of the product .
    I am using “storefront ” Theme i.e woocomerce free theme.

    On home page I want to show Read more button with description.
    Thanks

  10. here is the question

    1. Hi Eliza, what do you exactly mean with “excerpt from the second description”? Is that the long description?

  11. hey ! may you help me please to display the excerpt from the second description of the woocommerce. here is the website . The excerpt should be about the 100.

    Code from content-product.php

    <a href="”>

    $tab ) : $i++; ?>

    <div id="content_tab_” >

    the function that return me the product description is
    . I can’t figure out how to substr it

  12. Hi Rodolfo,

    Thank you again for the tip.
    $post->post_content didn’t work for me but $post_data->post_content did.

    I really appreciate your expertise and time. It helped me to get it working and understand a bit more. How exciting!

    Regards

  13. Hi Rodolfo,

    Thanks for getting back to me. I appreciate your time and expertise.
    I’m very new to web design as a hobby and fumbling through it.
    The code below gives me the product short description in the cart.
    What changes to this code will give me the long description in the cart?
    (the_content)

    add_filter( ‘woocommerce_get_item_data’, ‘wc_checkout_description_so_27900033’, 10, 2 );

    function wc_checkout_description_so_27900033( $other_data, $cart_item )
    {
    $post_data = get_post( $cart_item[‘product_id’] );
    $other_data[] = array( ‘name’ => ‘description’, ‘value’ => $post_data->post_excerpt );
    return $other_data;
    }

    thanks

    1. Try use $post->post_content instead of $post_data->post_excerpt ๐Ÿ™‚

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.