$added = array();
$args = array(
‘post_type’ => ‘post’,
‘posts_per_page’ => ‑1,
‘orderby’ => ‘meta_value’,
‘order’ => ‘ASC’,
‘meta_query’ => array(
array(
‘key’ => ‘first_contributor’,
),
),
);
$query = new WP_Query( $args );
if($query->have_posts()) :
while($query->have_posts()) :
$query->the_post();
if( get_field(‘first_contributor’))
{
$contributor1 = get_field(‘first_contributor’);
if( in_array($contributor1, $added) )
{
continue;
}
$added[] = $contributor1;
echo ‘;
echo $contributor1 . ’ (‘; ;
$args = array(
‘post_type’ => ‘post’,
‘posts_per_page’ => ‑1,
‘orderby’ => ‘date’,
‘order’ => ‘ASC’,
‘meta_query’ => array(
array(
‘value’ => $contributor1,
),
),
);
$my_query = new WP_Query( $args );
// stuff
$count = $my_query->post_count;
echo $count . ’)
’;
}
endwhile;
endif;
[/insert_php] [insert_php]$added = array();
$args = array(
‘post_type’ => ‘post’,
‘posts_per_page’ => ‑1,
‘orderby’ => ‘meta_value’,
‘order’ => ‘ASC’,
‘meta_query’ => array(
array(
‘key’ => ‘second_contributor’,
),
),
);
$query = new WP_Query( $args );
if($query->have_posts()) :
while($query->have_posts()) :
$query->the_post();
if( get_field(‘second_contributor’))
{
$contributor2 = get_field(‘second_contributor’);
if( in_array($contributor2, $added) )
{
continue;
}
$added[] = $contributor2;
echo ‘;
echo $contributor2 . ’ (‘; ;
$args = array(
‘post_type’ => ‘post’,
‘posts_per_page’ => ‑1,
‘orderby’ => ‘date’,
‘order’ => ‘ASC’,
‘meta_query’ => array(
array(
‘value’ => $contributor2,
),
),
);
$my_query = new WP_Query( $args );
// stuff
$count = $my_query->post_count;
echo $count . ’)
’;
}
endwhile;
endif;
[/insert_php]