0

i have a woocomemce site and the products have a "manufacturer" attribute.

when i get the terms for a single product :

  $terms= get_the_terms($product->id,"pa_manufacturer");

i get :

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 ) )

Can i do a loop WP_query only with that term_id to get products with the same manufacturer? How can i get only the products with that specific term_id?

here is my test, but not working...

$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 

Any help appreciated, thanks.

4

1 回答 1

2

您的问题出在您的查询中。Term_id 不是 WP_Query 的可用参数。这是可用参数的列表。我从http://phporlando.com/wp_query-argument-list/获得了列表

附件
附件ID
作者
作者姓名
猫
类别__和
类别__in
类别__not_in
分类名称
评论弹出窗口
天
错误
喂养
小时
分钟
月数
姓名
命令
订购
page_id
页
分页的
页面名称
发帖
post__not_in
post_status
post_type
预习
机器人
句子
第二
静止的
子帖
subpost_id
标记和
标签__in
标签__not_in
tag_id
tag_slug__and
tag_slug__in
标签
分类法 -(3.1 之前)
结核病
术语 -(3.1 之前)
w
带评论
没有评论
年

WP 3.1 之前

元密钥
元值

自 WP 3.1 起

字段
元查询
tax_query
于 2013-04-25T00:42:57.290 回答