Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Last active January 12, 2018 05:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuadavidnelson/364e77d0301e253e571c to your computer and use it in GitHub Desktop.
Save joshuadavidnelson/364e77d0301e253e571c to your computer and use it in GitHub Desktop.
Add the product description below the product, see: https://wordpress.org/support/topic/short-description-below-product. This is the updated code, using `get_the_excerpt()`
<?php
/**
* Add the product description (the excerpt of the cpt) below the product.
*
* @author Joshua David Nelson, josh@joshuadnelson.com
* @link https://wordpress.org/support/topic/short-description-below-product
*/
add_action( 'woocommerce_after_shop_loop_item_title', 'jdn_add_short_description', 9 );
function jdn_add_short_description() {
// Description linked to product
$url = get_the_permalink();
if( $url ) {
echo '<span class="title-description"><a href="' . $url . '">' . get_the_excerpt() . '</a></span><br />';
} else {
echo '<span class="title-description">' . get_the_excerpt() . '</span><br />';
}
}
@swdtrista
Copy link

Hi,

I added this into my function.php file of our child theme to have the description under the price in the listings page. It worked great, however then by boss decided she didn't really want this function and I deleted the code and saved the file. Since then I am seeing half of the description, I can't hide it with css or figure out how to get rid of it. Any help would be great, thanks so much!
https://www.sidewalkdog.com/product-category/patio-leash/

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