[英]Custom Taxonomy WooCommerce Rest API
我目前正在使用的Wordpress應用程序是使用WooCommerce和Tabify。
大多數字段都定義為自定義字段,我可以通過在查詢中添加filter[meta]=true
來獲得,但有兩個Status
和Region
已被定義為Custom Taxonomies。
我一直在尋找一種方法來使用Rest API獲取這些數據,但到目前為止還沒有運氣。
誰能指出我正確的方向?
我最終想通了。 也許這不是最實用的解決方案,每次我更新WooCommerce插件時都必須重新應用,但只需更新這樣的產品API
private function get_product_data( $product ) {
return array(
// your other properties go here
'region' => wp_get_post_terms( $product->id, 'productRegion', array( 'fields' => 'names' ) ),
'status' => wp_get_post_terms( $product->id, 'productActive', array( 'fields' => 'names' ) ),
)
}
現在我只是從響應中訪問region [0]和status [0]並做我需要做的任何事情。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.