【发布时间】:2019-02-09 22:19:07
【问题描述】:
我有一个 wp_query 来检索具有特定 meta_key/meta_value 的所有帖子类型,但我无法更改它,因为此查询在同一页面的其他 5 个循环中使用。
$posts = new WP_Query(array(
'posts_per_page' => -1,
'post_type' => 'item',
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'basicYear',
'value' => '1888',
'compare' => 'LIKE'
),
)
));
我有这个循环只显示特定字段的信息;
while( $posts->have_posts() ){
$posts->the_post();
the_field('relBrand', get_field('basicBrandName'));
}
我需要计算 the_field('relBrand', get_field('basicBrandName')); 的出现次数
例如:品牌 A (1)、品牌 B (6)、品牌 D (2);
有没有人知道如何在不改变 wp_query 的情况下做到这一点?
【问题讨论】: