Show Custom Short Description When Empty

The short WooCommerce product description is what appears to the right of the featured image above the “Add to Cart” button. Of course, unless you forgot to enter a short description under “Product”> “Edit Product”.

But if you forget to enter it or want to display a short global description, here is a short PHP snippet for you to use.

add_action( 'woocommerce_single_product_summary', 'codeithub_echo_short_desc_if_empty', 21 );
 
function codeithub_echo_short_desc_if_empty() {
   global $post;
   if ( empty ( $post->post_excerpt  ) ) {
      $post_excerpt = '<p class="default-short-desc">';
        $post_excerpt .= 'This is the default, global, short description.<br>It will show if <b>no short description has been entered!</b>';
        $post_excerpt .= '</p>';
      echo $post_excerpt;
   }
}

Before:

See also  Free Download on Archive Page Woocommerce
Default Single product page

After:

Global short description

Leave a Reply

Your email address will not be published. Required fields are marked *