Thanks Max, this pointed me in the right direction. I found some code that worked and adapted this to my needs. It works like a charm but the only thing that still bothers me is that I can not change the order in which the stages appear. Order is probably defined by what “stage” added first to wordpress.
<?php
$terms_array = array(
'taxonomy' => 'stages', // you can change it according to your taxonomy
'parent' => 0 // If parent => 0 is passed, only top-level terms will be returned
);
$stages_terms = get_terms($terms_array);
foreach($stages_terms as $stage): ?>
<div class="room">
<h4><?php echo $stage->name; ?></h4>
<?php
$post_args = array(
'posts_per_page' => -1,
'post_type' => 'artists', // you can change it according to your custom post type
'tax_query' => array(
array(
'taxonomy' => 'stages', // you can change it according to your taxonomy
'field' => 'term_id', // this can be 'term_id', 'slug' & 'name'
'terms' => $stage->term_id,
)
)
);
$myposts = get_posts($post_args); ?>
<ul>
<?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<a href="https://wordpress.stackexchange.com/questions/323086/<?php the_field("artist_external_link'); ?>" target="_blank"><?php the_title(); ?></a>
</li>
<?php endforeach; // Term Post foreach ?>
</ul></div>
<!-- end room -->
<?php wp_reset_postdata(); ?>
<?php endforeach; // End Term foreach; ?>