Woocommerce - description in products page

2019-03-21 14:30发布

问题:

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?

回答1:

That category page with the products inside is: 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.

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.

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.



回答2:

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