我是wordpress的新手,请推荐我。我卖戒指、耳环、链条等。环,耳“catogry”和环-1,环=2产品。所以我想在商店页面上显示我的catogry,然后单击catogry,我的产品将显示
WooCommerce-如何在产品上方显示产品类别和详细信息
2 个回复
最合适的回答,由SO网友:Nicolai Grossherr 整理而成
如果我没有完全错的话,你可以这样配置woocommerce
-购买类别1产品1。产品。2、类别2、产品2。1产品2。2
无需任何编码,从wordpress后端即可轻松访问:
“woocommerce>settings>catalog”
SO网友:thomas
谢谢,但我从其他渠道得到了答案。我的答案是
$args = array(
//\'number\'=> $number,
//\'orderby\'=> $orderby,
//\'order\'=> $order,
\'hide_empty\'=> false,
//\'include\'=> $ids
);
$product_categories = get_terms( \'product_cat\', $args );
foreach($product_categories as $catval)
{$catval->name;
$link = esc_url( get_term_link( $catval, $catval->taxonomy ) );
// get the thumbnail id user the term_id
$thumbnail_id = get_woocommerce_term_meta( $catval->term_id, \'thumbnail_id\', true );
// get the image URL
$image = wp_get_attachment_url( $thumbnail_id );
结束