2015-03-19 141 views
-1

自定义帖子是一个商店。每个城市都有很少的商店。 我需要显示在自定义帖子中从自定义字段中获取的城市列表,但我想删除重复项。任何帮助都会很棒。如何从Wordpress查询中删除自定义字段重复

$the_query = new WP_Query( 
array(
'numberposts' => -1, 
'post_type' => 'store', 
'meta_key' => 'city', 
'orderby'   => 'meta_value', 
'order'   => 'ASC', 
) 
); 
if ($the_query->have_posts()) { 
echo '<ul>'; 
while ($the_query->have_posts()) { 
    $the_query->the_post(); 
    echo '<li>' . get_field('city' ) . '</li>'; 
} 
echo '</ul>'; 
} else { 

} 
wp_reset_postdata(); 

回答

0

如果您使用城市的自定义分类标准,wordpress有税收查询可以过滤它们会容易得多。

+0

我是新来的。这是显而易见的,但除了我以外的所有:) – Bla 2015-03-19 12:48:21

+0

好专家也是新手一次:) – 2015-03-19 12:51:33