【发布时间】:2013-02-14 02:52:36
【问题描述】:
我有一个 woocomemce 网站,并且产品具有“制造商”属性。
当我获得单个产品的条款时:
$terms= get_the_terms($product->id,"pa_manufacturer");
我明白了:
Array ( [230] => stdClass Object ( [term_id] => 230 [name] => Dadawan [slug] => dadawan [term_group] => 0 [term_taxonomy_id] => 230 [taxonomy] => pa_manufacturer [description] => [parent] => 0 [count] => 4 [object_id] => 2905 ) )
我可以仅使用该 term_id 执行循环 WP_query 以获取同一制造商的产品吗? 我怎样才能只获得具有该特定 term_id 的产品?
这是我的测试,但不工作...
$args = array(
'post_type' => 'product',
'term_id' => 230 ,
'posts_per_page' => 2,
'orderby' => $orderby
);
$loop = new WP_Query( $args );
// Do stuff here to display your products
任何帮助表示赞赏,谢谢。
【问题讨论】:
标签: php wordpress woocommerce