From 5df38694e9f9130494c5a8b157dfb6a2cbc575a4 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 11 May 2014 00:26:14 +0000 Subject: [PATCH] In `get_the_author_posts()`, if there is no current `$post`, return `0` and bail. Props krogsgard, aaroncampbell. Fixes #27998. Built from https://develop.svn.wordpress.org/trunk@28362 git-svn-id: http://core.svn.wordpress.org/trunk@28190 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/author-template.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index b7361a0244..80fd6166ba 100644 --- a/wp-includes/author-template.php +++ b/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 ( ! $post ) { + return 0; + } + return count_user_posts( $post->post_author ); } /**