Execution of code goes to infinite loop because you missed the_post()
in loop.
You can list all authors from current category:-
- Create an empty array for author IDs
- Check if current author ID exist in that array
- If No, display the author name and store that author ID in array.
- If Yes, Then skip that post and move to next.
Consider this example:-
<div class="container">
<div class="row"><?php
if ( have_posts() ) {
$unique_authors = array();
while( have_posts() ) {
the_post(); ?>
<div class="col-md-2 text-center"><?php
if (!in_array(get_the_author_meta('ID'), $unique_authors)) {
the_author_meta( 'display_name' );
array_push($unique_authors, get_the_author_meta('ID'));
} ?>
</div><?php
}
} else { ?>
<p class="text-center">No authors</p><?php
} ?>
</div>
</div>