11.90K viewsWordPress
0

Adding excerpt to shop page, WordPress 中如何添加/设置在shop/product页面显示短描述?

0

添加到function.php

/* Adding excerpt to shop page */
add_action( 'woocommerce_after_shop_loop_item', 'diggs_custom_shop_item', 5);
function diggs_custom_shop_item() {
	global $post;
		/* product excerpt  */
	if ( $post->post_excerpt ) {
		echo '<div class="diggs-shop-excerpt">' . apply_filters( 'woocommerce_short_description', wp_trim_words($post->post_excerpt,6,' ') ) . '</div>';
	}
}