2016-08-06 46 views

回答

3

嗨,你可以使用postmeta表。

$primary_cat_id=get_post_meta($product->id,'_yoast_wpseo_primary_product_cat',true); 
if($primary_cat_id){ 
    $product_cat = get_term($primary_cat_id, 'product_cat'); 
    if(isset($product_cat->name)) 
     echo $product_cat->name; 
} 
+0

謝謝bharat。它節省了我大量的時間 – user1924744

相關問題