是的,当然可以。这是在页面加载中获取所有类别的代码,这段代码将一直持续到第三代类别。
$cats = get_categories( array(\'taxonomy\' => \'product_cat\', \'hide_empty\' => true) );
foreach ($cats as $key => $cat):
if ($cat->parent == 0):
echo $cat->name;
foreach ($cats as $key => $cat2):
if ($cat2->parent == $cat->term_id):
echo $cat2->name;
foreach ($cats as $key => $cat3):
if ($cat3->parent == $cat2->term_id):
echo $cat3->name;
endif;
endforeach;
endif;
endforeach;
endif;
endforeach;