Check for the existence of $post
before using it in get_the_ID()
. Return false
if it doesn't exist.
Props UmeshSingla. Fixes #17034. git-svn-id: https://develop.svn.wordpress.org/trunk@28844 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cf15c523d3
commit
b4c75b8ab1
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user