Ads by ProfitSence
Close

Get Post Author by Post id WordPress

Last Updated on Wednesday 5th Oct 2022
  • WordPress doesn’t have a function to get post's Author.
  • You can call to get the user ID for the author of a post.
			
					/**
 * @param int $post_id Post ID.
 *
 * @return int Post author ID.
 */
function get_post_author( $post_id ) {
  return get_post_field( 'post_author', $post_id );
}

			
	
  • get_post_author() function results in slightly better and more readable code.