I’m trying to add some text after a product description in WooCommerce which uses the $post->post_excerpt
. Currently I’m using the following code:
add_action( 'woocommerce_single_product_summary', 'd4tw_show_dimensions', 20 );
function d4tw_show_dimensions() {
global $product;
$dimensions = $product->get_dimensions();
if ( ! empty( $dimensions ) ) {
echo '<span class="dimensions"> Length: ' . $dimensions . '</span>';
}
}
This gets the dimensions to show up after the product summary but it’s on it’s own line. How can I append the dimensions within the same paragraph to the post_excerpt?
2 Answers
you may get the excerpt
using:
$excerpt = get_the_excerpt();
and append or prepend it as you wish