Skip to content

WooCommerce, Add Short or Long Description to Products on Shop Page

You can add a WooCommerce products’ long or short description to the actual product on the main shop page in WooCommerce via the woocommerce_after_shop_loop_item_title action hook, this hook places content immediately after the product title.

Adding the Long Description to the Product Loop on the Shop page

add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_long_description' );
/**
 * WooCommerce, Add Long Description to Products on Shop Page
 *
 * @link https://wpbeaches.com/woocommerce-add-short-or-long-description-to-products-on-shop-page
 */
function wc_add_long_description() {
	global $product;

	?>
        <div itemprop="description">
            <?php echo apply_filters( 'the_content', $product->post->post_content ) ?>
        </div>
	<?php
}

Adding the Short Description to the Product Loop on the Shop page

add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_short_description' );
/**
 * WooCommerce, Add Short Description to Products on Shop Page
 *
 * @link https://wpbeaches.com/woocommerce-add-short-or-long-description-to-products-on-shop-page
 */
function wc_add_short_description() {
	global $product;

	?>
        <div itemprop="description">
            <?php echo apply_filters( 'woocommerce_short_description', $product->post-> post_excerpt ) ?>
        </div>
	<?php
}

You can also limit the content character count by wrapping part of the function in a  substr function, so for example – limiting the full product description to 200 characters

add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_long_description' );
/**
 * WooCommerce, Add Long Description to Products on Shop Page with Character limit
 *
 * @link https://wpbeaches.com/woocommerce-add-short-or-long-description-to-products-on-shop-page
 */
function wc_add_long_description() {
	global $product;

	?>
        <div itemprop="description">
            <?php echo substr( apply_filters( 'the_content', $product->post->post_content ), 0,200 ); echo '...' ?>
        </div>
	<?php
}

So the above is now limited to 200 characters and also has an ellipse at the end.

ref

6 Comments

  1. katie on November 15, 2019 at 1:33 pm

    Hi,

    Bullet points don’t appear to show in these listings, anything I need to add to get ‘s working?

    Thanks

  2. PandaPsko on September 27, 2019 at 2:20 pm

    Actually none of those codes work on my site. It just doesn’t show any text. If someone can help, it would help me a lot.

  3. Marcial on June 29, 2019 at 5:27 pm

    Can this be done for all user roles except for just one?

  4. Anthony on June 5, 2019 at 6:43 am

    Hi,

    Thank you for the code! This doesn’t quite put the description directly after the title though, it adds it after the title and price.

    I found I had to change the following:
    add_action( ‘woocommerce_after_shop_loop_item_title’, ‘wc_add_long_description’ );
    to
    add_action( ‘woocommerce_shop_loop_item_title’, ‘wc_add_long_description’ );

  5. Tim on June 4, 2019 at 6:11 pm

    Thank you for this. Solved a big issue for me on an AJAX product filter I was using.

Leave a Comment





Scroll To Top