Skip to content

Instantly share code, notes, and snippets.

@leewillis77

leewillis77/functions.php Secret

Created Dec 3, 2018
Embed
What would you like to do?
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