Skip to content

Instantly share code, notes, and snippets.

@leewillis77
Created December 3, 2018 11:21
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 leewillis77/1f55fd91f7da2a3c190bca255d2642c7 to your computer and use it in GitHub Desktop.
Save leewillis77/1f55fd91f7da2a3c190bca255d2642c7 to your computer and use it in GitHub Desktop.
Use the short product description instead of description (WooCommerce pre-3.0)
<?php
function lw_woocommerce_gpf_description( $description, $product_id, $variation_id = null ) {
global $post;
if ( ! is_null( $variation_id ) ) {
$ID = $variation_id;
} else {
$ID = $product_id;
}
$save_post = $post;
$post = get_post( $ID );
if ( ! empty( $post->post_parent ) ) {
$post = get_post( $post->post_parent );
}
setup_postdata( $post );
$excerpt = get_the_excerpt();
$post = $save_post;
return $excerpt;
}
add_filter( 'woocommerce_gpf_description', 'lw_woocommerce_gpf_description', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment