-
-
Save leewillis77/1f55fd91f7da2a3c190bca255d2642c7 to your computer and use it in GitHub Desktop.
Use the short product description instead of description (WooCommerce pre-3.0)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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