WooCommerce 已经是 WordPress 平台最好最强大的在线商城插件，已经被 WordPress 收购，更新速度比较频繁，功能更加完善。

在频繁的更新后，一些常用的函数都在优化，一些字段也有所改变。Taji 主题在首页有一个模块『编辑推荐』，获取的是特色产品，在之前我们是可以通过以下代码就可以获取特色产品：

1. $args = array(
2. ‘post\_type’ =&gt; ‘product’,
3. ‘posts\_per\_page’ =&gt; 5,
4. ‘meta\_key’ =&gt; ‘\_featured’,
5. ‘meta\_value’ =&gt; ‘yes’
6. );

在 WooCommerce 3之后（具体哪个版本不确定），以上代码是获取不了特色产品，百度、谷歌都搜遍了也没有解决，WooCommerce 插件有提供一些简码，其中就有特色产品，所以查看了下简码才得到决定。

所以可以通过以下代码来获取 WooCommerce 的特色产品：

1. $args = array(
2. ‘post\_type’ =&gt; ‘product’,
3. ‘posts\_per\_page’ =&gt; 5,
4. ‘tax\_query’ =&gt; array(
5. array(
6. ‘taxonomy’ =&gt; ‘product\_visibility’,
7. ‘terms’ =&gt; ‘featured’,
8. ‘field’ =&gt; ‘name’,
9. ‘operator’ =&gt; ‘IN’,
10. ‘include\_children’ =&gt; false
11. )
12. )
13. );

以上只是解决方案，获取文件是使用`WP_Query`函数。