問題描述
我正在使用 WooCommerce 插件與 WordPress,在我的主題我想列出導航菜單中的所有類別與 PHP 。
我試過使用 woocommerce_product_categories();
但我不想要圖像或其他 HTML 元素,只是他們的名字 (或許是永久鏈接) 。
如何獲取這些數據?
最佳解決方案
取自相同的功能:
$args = array(
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids
);
$product_categories = get_terms( 'product_cat', $args );
將給您列出產品類別。簡單!
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。