0
我需要做一個自定義查詢返回所有產品適合我的查詢與他們的所有圖像,meta和所有「高級自定義字段」acf爲每個產品json格式。返回從woocommerce過濾產品列表
我部分成功使用下面的代碼:
function get_woocommerce_product_list($request) {
$query = array(
'post_type' => 'product',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_vendor',
'value' => 'farsi',
),
)
);
$result = [];
$wp_query = new WP_Query($query);
foreach ($wp_query->posts as $post) {
$result[$post->ID]['product'] = $post;
}
return $result;
}
任何幫助嗎?