2016-03-19 61 views
0

我想通過它的ID使用WP_Query在Wordpress中獲得特定的產品,我努力從昨天找到正確的參數。我卡住了。來自'product_cat'的分類標準WordPress的使用WP_Query獲得產品編號

$args = array(
    'post_type' => 'product', 
    'posts_per_page' => 1, 
    'id' => $product_id, 
); 

回答

1
$args = array(
    'post_type' => 'product', 
    'posts_per_page' => 1, 
    'post__in'=> array($product_id) 
); 
0

愚蠢的任務,但我找到了答案。保持我的大腦掙扎了這麼久......

$args = array(
    'post_type' => 'product', 
    'posts_per_page' => 1, 
    'post__in'=> array($id), 
); 
+0

如果你找到解決辦法,然後接受的答案。 –