I am using the OceanWP theme and Elementor Pro. I am using Elementor widgets: PRODUCTS and OceanWP widgets: WOO – PRODUCTS. These widgets do not allow you to display a SHORT PRODUCT DESCRIPTION from WooCommerce under the PRODUCT TITLE.
I have created two shortcodes in PHP that allow this. The description appears either at the very top of the product field or at the very bottom. Changing priorities does nothing. I cannot place the SHORT PRODUCT DESCRIPTION exactly between the PRODUCT NAME and its PRICE. Please help.
- PHP CODE for the Elementor widget – PRODUCTS:
// SHOWING A SHORT DESCRIPTION UNDER THE PRODUCT TITLE IN THE PRODUCTS WIDGET by Elementor
add_action( 'elementor/widget/render_content', function( $content, $widget ) {
// Check if it's a Products widget in Elementor
if ( 'woocommerce-products' === $widget->get_name() ) {
// Get the current HTML content of the widget
ob_start();
add_action( 'woocommerce_after_shop_loop_item', function() {
global $product;
$short_description = $product->get_short_description();
if ( $short_description ) {
echo '<div class="elementor-product-short-description" style="margin-top: 5px; font-size: 14px; color: #666;">';
echo wp_kses_post( $short_description );
echo '</div>';
}
}, 15 );
ob_end_flush();
}
return $content;
}, 10, 2 );
- PHP CODE for the OceanWP widget – WOO – PRODUCTS:
// DISPLAYING A SHORT DESCRIPTION UNDER THE PRODUCT TITLE IN THE WIDGET WOO - PRODUCTS by OceanWP
add_action( 'woocommerce_after_shop_loop_item_title', function() {
global $product;
if ( ! $product ) {
return;
}
// Download a short description of the product
$short_description = $product->get_short_description();
// If the description exists, we add it ONLY under the title
if ( $short_description ) {
echo '<div class="elementor-product-short-description" style="margin-top: 5px; font-size: 14px; color: #666;">';
echo wp_kses_post( $short_description );
echo '</div>';
}
}, 15 ); // We changed the priority to 15 so that it is AFTER the title but before the price and button
Best regards,
Krzysztof