![](/img/trans.png)
[英]Target WooCommerce product category archive pages from a child category term
[英]Get current term name in Woocommerce product category archive pages
我正在嘗試獲取產品類別存檔頁面的單個產品類別名稱。
使用此代碼:
$categ = $product->get_categories();
echo $categ;
它也顯示所有父類別...
如何在Woocommerce產品類別歸檔頁面中獲得當前術語名稱?
要獲取當前產品類別歸檔頁面的產品類別術語名稱,您將使用:
// Only on product category archive pages
if(is_product_category()){
// The WP_Term object for the current product category
$term = get_queried_object();
// Get the current term name for the product category page
$term_name = $term->name;
// Test output
echo $term->name . '<br>';
}
經過測試和工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.