所有分类

    'product_cat', 'parent' => 0, 'hide_empty' => false ); $categories = get_terms($args); foreach($categories as $category) { echo '
  • '.$category->name.'
  • '; } ?>
term_id, 'thumbnail_id', true); $image = wp_get_attachment_url($thumbnail_id); echo '
'; echo '

'.$category->name.'

'; // 获取二级分类 $child_args = array( 'taxonomy' => 'product_cat', 'parent' => $category->term_id, 'hide_empty' => false ); $child_categories = get_terms($child_args); echo '
'; foreach($child_categories as $child) { echo '
'; echo '
'.$child->name.'
'; // 获取三级分类 $grandchild_args = array( 'taxonomy' => 'product_cat', 'parent' => $child->term_id, 'hide_empty' => false ); $grandchild_categories = get_terms($grandchild_args); if(!empty($grandchild_categories)) { echo ''; } echo '
'; } echo '
'; } ?>