Skip to content

Instantly share code, notes, and snippets.

@jhimross
Created January 27, 2022 04:54
Show Gist options
  • Save jhimross/5b674f2f21a6de702f0b30fecb35250f to your computer and use it in GitHub Desktop.
Save jhimross/5b674f2f21a6de702f0b30fecb35250f to your computer and use it in GitHub Desktop.
WooCommerce Show Single Variations - Show Parent Product Description in Variations
/**
* Show parent's short description for variations.
*
* @param string $excerpt
* @param $post
*
* @return string
*/
function iconic_get_the_excerpt( $excerpt, $post ) {
if ( 'product_variation' !== $post->post_type ) {
return $excerpt;
}
$parent_id = $post->post_parent;
return get_the_excerpt( $parent_id );
}
add_filter( 'get_the_excerpt', 'iconic_get_the_excerpt', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment