这就是代码缩进如此重要的原因!你的posts_per_page
参数实际上是tax\\u查询的一部分:
\'post_type\' => \'regularproducts\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'products-category\',
\'field\' => \'slug\',
\'terms\' => $course_terms, //the taxonomy terms I\'d like to dynamically query
\'posts_per_page\' => \'4\'
),
),
\'orderby\' => \'title\',
相反,您应该:
$wp_query = new WP_Query(
array(
\'posts_per_page\' => \'4\',
\'post_type\' => \'regularproducts\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'products-category\',
\'field\' => \'slug\',
\'terms\' => $course_terms, //the taxonomy terms I\'d like to dynamically query
),
),
\'orderby\' => \'title\',
\'order\' => \'ASC\',
)
);