计算一个职位类型中有特定期限的职位数量的最佳方法是什么?我不相信get_posts
接受术语查询,但我在new WP_Query
, 虽然我可能做错了什么。
用法示例:
$posts = get_posts( array(
\'post_type\' => \'inventory\',
array(
\'taxonomy\' => \'status\',
\'terms\' => \'in-stock\',
\'field\' => \'slug\'
),
) );
$count = count( $posts );
echo $count;
最合适的回答,由SO网友:mfields 整理而成
$items = get_posts( array(
\'post_type\' => \'inventory\',
\'numberposts\' => -1,
\'taxonomy\' => \'status\',
\'term\' => \'in-stock\'
) );
$count = count( $items );
echo $count;