Welcome @MoJones. As has been discovered in this thread this is caused by theme code doing something unexpected. It’s usually also a good idea to search for these error messages and see if they have been reported by WP users. In this case: https://core.trac.wordpress.org/ticket/47824
This issue has been fixed in WP 5.5 (so the same warning would have also appeared in WP 5.4 and earlier). I’ll put it on the list to fix in an upcoming CP release but it depends on some other changes so we’ll need to be careful with that (and we are too close to our upcoming
1.2.0 release so it won’t make it in there).
I wouldn’t recommend changing
wp-includes/post-template.php like that - those couple of lines of code have to do with several different scenarios, mostly related to displaying lists of posts across multiple pages. Also, any changes made there will be overwritten on the next upgrade.
Instead if you can find where your theme code calls
the_content() or possibly
the_excerpt() outside of “the loop” (i.e. not in between
while ( have_posts() ) and
endwhile) then we can make a modification there. The file to look in depends on where this issue occurs. For example, if you see this warning when viewing single blog posts or pages on your site then you probably want
Anyway once you find a call to any of these four functions
get_the_excerpt() that is not contained within
while ( have_posts() ) you should be able to modify that line as follows.
$GLOBALS['pages'] = array(); the_content();
Hope that helps… at least, that should be enough to avoid the current warning if I’ve got my understanding of the issue right.