Try it:
<?php echo get_the_author_meta( 'display_name', $post->post_author ); ?>
You can use the_author
function in wordpress standard loop, Not foreach. to set global author information you should use the_post
function. but in foreach, you can use get_the_author_meta
instead of the_author
to pass author id $post->post_author
.