Tag: woocommerce

Total 2 Posts

WooCommerce, aggiungere una descrizione breve o lunga ai prodotti nella pagina del negozio

E’ spiegato qui. Bisogna editare il file functions.php del proprio tema.

Descrizione lunga
add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_long_description' );
/**
 * WooCommerce, Add Long Description to Products on Shop Page
 *
 * @link https://wpbeaches.com/woocommerce-add-short-or-long-description-to-products-on-shop-page
 */
function wc_add_long_description() {
	global $product;

	?>
        <div itemprop="description">
            <?php echo apply_filters( 'the_content', $product->get_description() ) ?>
        </div>
	<?php
}
Descrizione corta
add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_short_description' );
/**
 * WooCommerce, Add Short Description to Products on Shop Page
 *
 * @link https://wpbeaches.com/woocommerce-add-short-or-long-description-to-products-on-shop-page
 */
function wc_add_short_description() {
	global $product;

	?>
        <div itemprop="description">
            <?php echo apply_filters( 'woocommerce_short_description', $product->get_short_description() ) ?>
        </div>
	<?php
}

Se invece volessimo limitare la descrizione completa a n caratteri (nell’esempio 200 caratteri):

add_action( 'woocommerce_after_shop_loop_item_title', 'wc_add_long_description' ); /**  * WooCommerce, Add Long Description to Products on Shop Page with Character limit  *  * @link https://wpbeaches.com/woocommerce-add-short-or-long-description-to-products-on-shop-page  */ function wc_add_long_description() { global $product; ?>         <div itemprop="description">             <?php echo substr( apply_filters( 'the_content', $product->get_description() ), 0,200 ); echo '...' ?>         </div> <?php }