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?

  • 1
    This is most probably a CSS question and off topic for that site. Nevertheless: Have a look at the class that the excerpt is using. Possibily it´s set to display:block; which causes your appendix to start on a new line. Change it to inline-block or even inline to have it fixed.
    – flomei
    Jan 27 '16 at 15:18
  • Interesting...I'm still learning WordPress but know css pretty well and I just never thought of that solution. Excellent! Jan 28 '16 at 12:06
  • Was my answer helpful to you?! Please accept and upvote if was helpful
    – Pmpr
    Mar 28 '20 at 16:08

you may get the excerpt using:

$excerpt = get_the_excerpt();

and append or prepend it as you wish


I ended up just setting the paragraph to display:inline-block which allowed the product dimensions to flow up onto that line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.