のトップレベルの製品カテゴリのカスタム配列であるになってしまうが、ここに私のテーマの中にカスタムセクションに</p> <p>それらを表示するためにwoocomerceでトップレベルの製品カテゴリの一覧を取得するがどのような方法は、私が使用するコードWooCommerce
'child_of' => 0
をしかし、変更はありません。私は最近追加した
function getCategoriesList() {
// prior to wordpress 4.5.0
$args = array(
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids
);
$product_categories = get_terms('product_cat', $args);
// since wordpress 4.5.0
$args = array(
'taxonomy' => "product_cat",
'child_of' => 0,
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids
);
$product_categories = get_terms($args);
$list = array();
foreach($product_categories as $cat){
$thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
$link = get_term_link($cat->term_id, 'product_cat');
$list[] = array($cat->term_id, $cat->name, $image, $link);
}
return $list;
}
:それはすべてのカテゴリを返します。
トップレベル製品カテゴリのみで動作させる方法を教えてください。