From c725b77068c0a9fb9675a4603c3ce52eea52307a Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 26 Jun 2014 02:05:14 +0000 Subject: [PATCH] Check for the existence of `$post` before using it in `get_the_ID()`. Return `false` if it doesn't exist. Props UmeshSingla. Fixes #17034. Built from https://develop.svn.wordpress.org/trunk@28844 git-svn-id: http://core.svn.wordpress.org/trunk@28648 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-template.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index ed49895ecd..0f1570a21b 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -23,10 +23,11 @@ function the_ID() { * @since 2.1.0 * @uses $post * - * @return int + * @return int|bool The ID of the current item in the WordPress Loop. False if $post is not set. */ function get_the_ID() { - return get_post()->ID; + $post = get_post(); + return ! empty ( $post ) ? $post->ID : false; } /**