I am trying to build a navigation filter for a custom post type I've developed and I am building a navigation tool to filter the results by meta value used in all posts.
With the code I'm using, it displays all meta values, and in some cases repeats 4-5 times because there are 4-5 posts with that value.
I'd like to just get the list, but limit the number of times each is mentioned.
Here is what I've setup.
$ministry = $_GET['m'];
'post_type' => $type,
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'ministry',
'meta_value' => $ministry,
'orderby' => 'ministry',
'order' => 'ASC');
then to display
while ($my_query->have_posts()) : $my_query->the_post(); ?>
$ministry = get_post_meta($post->ID, 'ministry', true);
echo $ministry; ?>
I understand why it is doing this based on what I am asking for, but I'd like to know how to limit what its returning.