wordpress Woocommerce - 产品页面中的描述

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15479712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:11:48  来源:igfitidea点击:

Woocommerce - description in products page

wordpresscontent-management-systemwordpress-plugin

提问by Mythago

I need to add little excerpt from description on my "product" in Woocommerce plugin. I have page like this: http://exploreprague.cz/guides-buddies-2/and I need to have some description text under the name of each person... is there any way to do it?

我需要从 Woocommerce 插件中的“产品”描述中添加一些摘录。我有这样的页面:http: //exploreprague.cz/guides-buddies-2/我需要在每个人的名字下都有一些描述文本......有什么办法吗?

回答by Jason Weber

That category page with the products inside is: woocommerce >> templates >> content-product.php

里面有产品的那个分类页面是:woocommerce >> templates >> content-product.php

And you can find that only function to show the Title inside this page as:

您会发现只有在此页面内显示标题的功能为:

<h3><?php the_title(); ?></h3>

After that line you can add your own lines:

在该行之后,您可以添加自己的行:

<br /><?php echo $product->get_sku(); ?> <br /><?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>

These will display the SKU and the short-description of the product.

这些将显示 SKU 和产品的简短描述。

Btw, this is just a quick hard-coded method, you can try to add these functions to the hook on that page in your theme's functions.php.

顺便说一句,这只是一个快速的硬编码方法,您可以尝试将这些函数添加到主题的functions.php 中该页面上的钩子中。

add_action('woocommerce_after_shop_loop_item_title','woocommerce_template_single_excerpt', 5);

As it is mentioned in that hooks comments section that the PRICE is already hooked in there.

正如在钩子评论部分中提到的那样,价格已经被钩住了。

回答by Martin Tonev

Maybe this can help you

也许这可以帮助你

<?php wc_get_template( 'single-product/short-description.php' ); ?>

from this link https://docs.woothemes.com/wc-apidocs/function-woocommerce_template_single_excerpt.html

从这个链接https://docs.woothemes.com/wc-apidocs/function-woocommerce_template_single_excerpt.html