From d7599e834d681ec6cdfc48baa6ae9e93849541c7 Mon Sep 17 00:00:00 2001
From: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date: Sat, 3 Mar 2018 19:31:00 -0600
Subject: [PATCH] Handle negative page indexes in get_the_content

---
 wp-includes/post-template.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 9bbfd764b0..35804c5c59 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -292,6 +292,9 @@ function get_the_content( $more_link_text = null, $strip_teaser = false ) {
 	if ( $page > count( $pages ) ) { // if the requested page doesn't exist
 		$page = count( $pages ); // give them the highest numbered page that DOES exist
 	}
+	else if ( $page < 1 ) { // or if the requested page was zero or not set
+		$page = 1; // return the first page instead
+	}
 
 	$content = $pages[ $page - 1 ];
 	if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
-- 
2.16.1

