您是否尝试过简单地省略\'terms\'
来自的键\'tax_query\'
大堆
$query03 = array(
\'numberposts\' => 5,
\'post_type\' => array(
\'video\'
),
\'tax_query\' => array(
array(
\'taxonomy\' => \'product\',
\'field\' => \'slug\'
)
)
);
或者,我也不会真正担心查询的权重。无论查询参数有多复杂,或查询参数数组有多大,结果查询都将是它将是什么。因此,我建议通过
get_terms
:
<?php get_terms( $taxonomy, $args ); ?>
通过设置
\'fields\'
到
\'ids\'
, 将返回术语ID数组,而不是术语对象数组):
$query03 = array(
\'numberposts\' => 5,
\'post_type\' => array(
\'video\'
),
\'tax_query\' => array(
array(
\'taxonomy\' => \'product\',
\'field\' => \'id\',
\'terms\' => get_terms( \'product\', array( \'fields\' => \'ids\' ) )
)
)
);
编辑备选方案
tax_query
\', 使用术语段塞代替ID:
\'tax_query\' => array(
array(
\'taxonomy\' => \'product\',
\'field\' => \'slug\',
\'terms\' => get_terms( \'product\', array( \'fields\' => \'names\' ) )
)
)