Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 在WooCommerce归档页面的产品标题下添加简短说明_Wordpress_Woocommerce_Wordpress Theming - Fatal编程技术网

Wordpress 在WooCommerce归档页面的产品标题下添加简短说明

Wordpress 在WooCommerce归档页面的产品标题下添加简短说明,wordpress,woocommerce,wordpress-theming,Wordpress,Woocommerce,Wordpress Theming,我的网站是。我试图通过以下链接将WooCommerce产品的简短描述添加到实现页面网格(在产品标题下),但没有成功。什么也没出现 我正在使用。有人能帮忙吗?你可以用woocommerce\u after\u shop\u loop\u item\u title hook来完成 add_action('woocommerce_after_shop_loop_item_title','my_product_description'); function my_product_descr

我的网站是。我试图通过以下链接将WooCommerce产品的简短描述添加到实现页面网格(在产品标题下),但没有成功。什么也没出现


我正在使用。有人能帮忙吗?

你可以用woocommerce\u after\u shop\u loop\u item\u 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;

}

在theme 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 );

这对我有用。

谢谢。我应该把它添加到funitions.php中,对吗?尝试过了,但它不起作用。致命错误:无法在shop\u loop\u item\u title()之后重新声明操作\u woocommerce\u(之前在/home/outlet.ltd/public\u html/wp content/plugins/code snippets/php/snippet ops.php(469):eval()'d code:3中声明)在第1797行的/home/outlet.ltd/public\u html/wp-content/themes/rehub-theme/functions.php中,您需要将操作函数名称action\u woocmerce\u after\u shop\u loop\u item\u title更改为my\u action\u woocmerce\u after\u shop\u loop\u item\u title。所以代码如下:函数my_action_woocommerce_after_shop_loop_item_title(){global$product;if(is_shop()):echo$product->get_short_description();endif;};添加动作(“购物循环项目标题后的woocommerce”和“我的动作循环项目标题后的woocommerce”,5);