diff --git wp-includes/author-template.php wp-includes/author-template.php
index dd225c0..9447ebb 100644
--- wp-includes/author-template.php
+++ wp-includes/author-template.php
@@ -206,7 +206,11 @@ function the_author_link() {
  * @return int The number of posts by the author.
  */
 function get_the_author_posts() {
-	return count_user_posts( get_post()->post_author );
+	$post = get_post();
+	if ( empty( $post ) ) {
+		return 0;
+	}
+	return count_user_posts( $post->post_author );
 }
 
 /**
