diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index 3d82ba81b641b..8c08bd5acc33f 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -26,7 +26,12 @@ function the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionNam */ function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid $post = get_post(); - return ! empty( $post ) ? $post->ID : false; + + if ( ! $post instanceof WP_Post ) { + return false; + } + + return $post->ID; } /**