Skip to content

Instantly share code, notes, and snippets.

@criespy
Forked from om4james/functions.php
Last active August 10, 2020 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save criespy/d64d35ebf5ed2ed8ba543a48b3d64822 to your computer and use it in GitHub Desktop.
Save criespy/d64d35ebf5ed2ed8ba543a48b3d64822 to your computer and use it in GitHub Desktop.
Display product description on WooCommerce shop/category pages
<?php
/**
* Add the product's short description (excerpt) to the WooCommerce shop/category pages. The description displays after the product's name, but before the product's price.
*
* Ref: https://gist.github.com/om4james/9883140
*
* Put this snippet into a child theme's functions.php file
*/
function woocommerce_after_shop_loop_item_title_short_description() {
global $product;
if ( ! $product->post->post_excerpt ) return;
?>
<div itemprop="description">
<?php echo apply_filters( 'woocommerce_short_description', substr($product->post->post_excerpt, 0, 60) )."..."; ) ?>
</div>
<?php
}
add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_after_shop_loop_item_title_short_description', 5);
@criespy
Copy link
Author

criespy commented Aug 10, 2020

add limit for displaying character to 60, add "..." after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment