Hey,
I’m currently building an nightclub website with WordPress and a lot of ACF’s features. There’s one query I cant wrap my head around.
At a custom post type called event you can select artists from a custom post type called.. artists. I use a Relation ACF field for this.
I managed to build a query to view all events the artist is related to at a single artist page.
<?php
$posts = get_posts(array(
'post_type' => 'agenda',
'posts_per_page' => -1,
'meta_key' => 'datum', // Dutch for Date
'orderby' => 'datum',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'artiesten',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE',
)
)
));
?>
Now I would like to create a page with the most billed artist per year. Is this possible in a single query? I could loop all artists and include a second loop to count the events the artist is billed on, but I don’t think my server agrees with a big artist database.
Help is greatly appreciated!
Sample event page: http://www.perron.nl/agenda/2manydjs-2/
Sample artist page: http://www.perron.nl/artists/samnesia/