WooCommerce 产品类别(图片、标题、link + 描述)

WooCommerce product category (image, title, link + description)

(woocommerce 版本 2.4.6 - wordpress 版本 4.2.2)

我想在主页上显示 3 个产品类别(图片、标题、link + 描述:针对每只猫)

我试试这个

        <?php
// Déterminer des informations des catégories des produits
$args = array(
    'number'     => $number,
    'orderby'    => 'slug',
    'order'      => 'ASC',
    'hide_empty' => $hide_empty,
    'include'    => $ids
);
$product_categories = get_terms( 'product_cat', $args );
// Déterminer le nombre de catégories
$count = count($product_categories);
if ( $count > 0 ){ // S'il y a au moins une catégorie
    foreach ( $product_categories as $product_category ) {
        // Déterminer l'identifiant de la vignette d'une catégorie
        $thumbnail_id = get_woocommerce_term_meta( $product_category->term_id, 'thumbnail_id', true );
        // Extraire l'URL de la vignette
        $thumbnail_url = wp_get_attachment_thumb_url( $thumbnail_id );
        // Aficher la vignette et le nom de la catégorie comme un lien vers la page de la catégorie
        echo '<h2><img src="'.$thumbnail_url.'" /><a href="' . get_term_link( $product_category ) . '"> ' . $product_category->name . '</a></h2>';
    }
}

?>

..但它缺少描述,我只会特别显示类别 3(例如 id 90、91、92)

也许用简码?

感谢

// Déterminer des informations des catégories des produits
$args = array(
   'number'     => $number,
   'orderby'    => 'slug',
   'order'      => 'ASC',
   'hide_empty' => $hide_empty,
   'include'    => $ids,
   'product_cat' => array(90,91,92), //add this in args
);

添加这一行

echo $product_category->description;

之后
echo '<h2><img src="'.$thumbnail_url.'" /><a href="' . get_term_link( $product_category ) . '"> ' . $product_category->name . '</a></h2>';