更新时间:2023-12-01 23:16:28
您可以使用 postmeta 表.
Hi you can get using postmeta table.
$taxonomy = 'product_cat';
$primary_cat_id=get_post_meta($product->id,'_yoast_wpseo_primary_' . $taxonomy, true);
if($primary_cat_id){
$primary_cat = get_term($primary_cat_id, $taxonomy);
if(isset($primary_cat->name))
echo $primary_cat->name;
}