diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
index b80ac4d..61575af 100644
--- src/wp-includes/post-template.php
+++ src/wp-includes/post-template.php
@@ -262,6 +262,10 @@ function get_the_content( $more_link_text = null, $strip_teaser = false ) {
$post = get_post();
+ if( empty( $post ) ) {
+ return '';
+ }
+
if ( null === $more_link_text ) {
$more_link_text = sprintf(
'%2$s',
diff --git tests/phpunit/tests/post/output.php tests/phpunit/tests/post/output.php
index cc1e4ea..abf7ced 100644
--- tests/phpunit/tests/post/output.php
+++ tests/phpunit/tests/post/output.php
@@ -57,6 +57,14 @@ EOF;
$this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
}
+ /**
+ * @ticket 39992
+ */
+ function test_get_the_content_should_return_empty_string_with_no_global_post_object() {
+ unset( $GLOBALS['post'] );
+ $this->assertEmpty( get_the_content() );
+ }
+
function test_the_content_shortcode() {
$post_content = <<