0
votes

Hello thanks for reading, Just had a issue regarding woocommerce, I want to add a short 5-10 word description for each product on the shop page. Do i create a custom field, fill out the short description section??

I don't want it to appear on the product description page (when you click the product)

Sorry new to wordpress/woocommerce!

Would post an image for example but don't have enough rep :(

Thanks!

3
Please use the the_excerpt(); codex to display short description.craig

3 Answers

0
votes

To add a short 5-10 word description for each product on the shop page

create a function and then hook to that filter... something like this...

add_filter('woocommerce_short_description', 'limit_woocommerce_short_description', 10, 1);
function limit_woocommerce_short_description($post_excerpt){
    if (!is_product()) {
    $pieces = explode(" ", $post_excerpt);
    $post_excerpt = implode(" ", array_splice($pieces, 0, 10));
    }
    return $post_excerpt;
}

paste this in your functions.php file of your theme.

and use below code where you want to display product description -

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

use this code to change word limit on the Shop Page not Product-detailed Page.

0
votes

In functions.php you can add the code below for having the short description on each product when viewing them in shop page.Afterwards, you can change it through php code or javascript.

add_action( 'woocommerce_after_shop_loop_item_title', 'output_product_excerpt', 35 );

function output_product_excerpt() {
global $post;
echo $post->post_excerpt;
}

Hope that helps.

-1
votes
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_single_excerpt', 5);