【问题标题】:Using 'post_type' => 'product' in woocommerce在 woocommerce 中使用 'post_type' => 'product'
【发布时间】: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


    【解决方案1】:

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

    附件 附件ID 作者 作者姓名 猫 类别__和 类别__in 类别__not_in 分类名称 cmets_popup 天 错误 喂养 小时 分钟 月数 姓名 命令 订购 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 带子 没有cmets 年 WP 3.1 之前 元密钥 元值 自 WP 3.1 起 字段 元查询 tax_query

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-09
      • 2016-03-24
      • 1970-01-01
      • 2016-11-21
      • 2020-08-23
      • 1970-01-01
      • 2018-11-08
      • 1970-01-01
      相关资源
      最近更新 更多