xxxxxxxxxx
$author_id = get_post_field( 'post_author', $post_id ); // get the author ID of the current post
$author_name = get_the_author_meta( 'display_name', $author_id ); // get the display name of the author
echo 'Written by ' . $author_name;
xxxxxxxxxx
public static function get_author_outside_loop() {
global $post;
return get_the_author_meta( 'display_name', $post->post_author );
}