How to get author ID by post ID? WordPress

To get the author ID from a post ID, use this code:

$post_id = 422;
$author_id = get_post_field( 'post_author', $post_id );

Leave a comment

Your email address will not be published. Required fields are marked *