admin管理员组文章数量:1333211
I'm running a simple query just to find simple WooCommerce products, here is the query which works fine in the header of the site:
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'product_type',
'field' => 'slug',
'terms' => array('simple')
),
),
);
$simpleProducts = new WP_Query($args);
This query returns 1065 products which are correct. If I run the same query through a WP CLI command, I get 0 posts... however, if I remove the tax query it's returns all the products on the site.
Here is the command that runs:
// Add the command.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
\WP_CLI::add_command('update-stock', \stockChecker::syncStockFile());
}
Has anyone had this issue with WP CLI?
EDIT
To add, this runs fine:
$args = array(
'post_type' => 'product_variation',
'posts_per_page' => -1,
);
$products = new WP_Query($args);
本文标签: woocommerce offtopicWP WPQuerynot running properly in WP CLI
版权声明:本文标题:woocommerce offtopic - WP WPQuery, not running properly in WP CLI 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742285881a2446918.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论