Created
January 27, 2022 04:54
-
-
Save jhimross/5b674f2f21a6de702f0b30fecb35250f to your computer and use it in GitHub Desktop.
WooCommerce Show Single Variations - Show Parent Product Description in Variations
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
/** | |
* 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