[英]Add short description under the product title in WooCommerce archive pages
My site is https://outlet.ltd/deals .我的网站是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.
我尝试通过以下链接将 WooCommerce 产品的简短描述添加到实现页面网格(在产品标题下),但没有成功。 Nothing shows up.
什么都没有出现。
Add shortened description under the product title in WooCommerce archive pages 在 WooCommerce 存档页面的产品标题下添加简短描述
I'm using REHub theme .我正在使用REHub 主题。 Could anyone help?
有人可以帮忙吗?
You can do it with woocommerce_after_shop_loop_item_title hook你可以用 woocommerce_after_shop_loop_item_title 钩子来做
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;
}
Add this code on your theme functions.php file.将此代码添加到您的主题 functions.php 文件中。
// 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.这个对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.