-2

My site is https://outlet.ltd/deals. I tried to add a short description of the WooCommerce product to the achieve page grid (under product title) by following links but was not successful. Nothing shows up.

I'm using REHub theme. Could anyone help?

JOY
  • 399
  • 3
  • 15

2 Answers2

0

You can do it with woocommerce_after_shop_loop_item_title hook

add_action('woocommerce_after_shop_loop_item_title','my_product_description');

function my_product_description() {

// get the global product obj

    global $product;

// get the global product obj

 $description = $product->get_short_description();

echo $description;

}
Gozer
  • 11
  • 10
0

Add this code on your theme functions.php file.

// define the woocommerce_after_shop_loop_item_title callback 
function action_woocommerce_after_shop_loop_item_title(  ) { 
    global $product;
    if( is_shop() ):
        echo $product->get_short_description();
    endif;
}; 
         
// add the action 
add_action( 'woocommerce_after_shop_loop_item_title', 'action_woocommerce_after_shop_loop_item_title', 5 );

it works for me.

sumon cse-sust
  • 434
  • 4
  • 8
  • Fatal error: Cannot redeclare action_woocommerce_after_shop_loop_item_title() (previously declared in /home/outlet.ltd/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()'d code:3) in /home/outlet.ltd/public_html/wp-content/themes/rehub-theme/functions.php on line 1797 – JOY Apr 18 '21 at 08:36
  • You need to change the action function name action_woocommerce_after_shop_loop_item_title to my_action_woocommerce_after_shop_loop_item_title. So code will be like this: function my_action_woocommerce_after_shop_loop_item_title( ) { global $product; if( is_shop() ): echo $product->get_short_description(); endif; }; add_action( 'woocommerce_after_shop_loop_item_title', 'my_action_woocommerce_after_shop_loop_item_title', 5 ); – sumon cse-sust Apr 24 '21 at 06:30