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 Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>