简体   繁体   English

在简短描述之前更改 WooCommerce 单个产品名称位置

[英]Change WooCommerce single product name location before short description

I'm trying to display the product name on top of the "short product description".我试图在“简短的产品描述”之上显示产品名称。

I have been told that this can be accomplished by using PHP, which I know nothing of.有人告诉我,这可以通过使用 PHP 来完成,我对此一无所知。 The only way I can use a PHP function in the desired space is using HTML, which I saw that can be used with:我可以在所需空间中使用 PHP 函数的唯一方法是使用 HTML,我看到它可以用于:

<div><?php $functiongoeshere();></div>

This is on a wordpress/woocommerce site, you can see a product example by clicking here .这是在 wordpress/woocommerce 网站上,您可以单击此处查看产品示例。

Could someone please help me?有人可以帮我吗?

To move product title before product description in single product pages, try to use the following:要在单个产品页面中的产品描述之前移动产品标题,请尝试使用以下内容:

add_action( 'woocommerce_single_product_summary', 'move_single_product_title', 1 );
function move_single_product_title(){
    remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); 
    add_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 15 );
}

Code goes in functions.php file of your active child theme (or active theme).代码位于活动子主题(或活动主题)的 functions.php 文件中。 It should works.它应该有效。

See: WooCommerce action hooks and overriding templates请参阅: WooCommerce 操作挂钩和覆盖模板

This is not css matter, it's php, you need to find tpl file that controls single product page.这不是css的问题,是php,你需要找到控制单品页面的tpl文件。

In woocommerce its called something like single-product.tpl but theme can affect it.在 woocommerce 中,它被称为类似 single-product.tpl 的东西,但主题会影响它。

find line that echoes title and than you can copy this to another section, in your case description.找到与标题相呼应的行,然后您可以将其复制到另一个部分,在您的案例描述中。

That way every product will display name in description as well这样每个产品也会在描述中显示名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM