在价格下添加简短描述

时间:2021-12-20 作者:Mayank Verma

试图建立一个网站,但似乎默认情况下,它不会显示页面上的简短描述。

我想把简短的描述放在价格下面。尝试了很多东西,但都没什么效果,只是希望有人能在这方面提供帮助

以下是url:https://moratofabs.com/product/cotton-60x60-fabric-block-design-anarkali-kurti-with-pant-and-dupatta-gotalace-and-heavy-adda-worked-on-yoke/

我想在产品价格下面写一个简短的描述

1 个回复
SO网友:Buttered_Toast

查看content-single-product.php 在woocommerce github,我看到产品摘录应该是在价格之后

/**
* Hook: woocommerce_single_product_summary.
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
* @hooked WC_Structured_Data::generate_product_data() - 60
*/
do_action( \'woocommerce_single_product_summary\' );
所以要么你的主题是删除这个动作,要么你没有使用摘录。

如果您没有使用摘录,也看不到产品的主题,可以在下面激活它screen options 选项卡(如果系统语言为LTR,则位于右上角)。

如果你有摘录,但没有看到它,你将需要连接到woocommerce_single_product_summary 优先级在11到29之间(如果其他行动与优先级20挂钩,甚至可能在11到19之间)
例如

add_action(\'woocommerce_single_product_summary\', \'bt_custom_product_description\', 15);
function bt_custom_product_description () {
    echo \'Some description here\';
}

相关推荐

OOP development and hooks

我目前正在为Wordpress编写我的第一个OOP插件。为了帮助我找到一点结构,a boiler plate 这为我奠定了基础。在里面Main.php 有一种方法可以为管理员加载JS和CSS资产:/** * Register all of the hooks related to the admin area functionality * of the plugin. * * @since 0.1.0 * @access private