Make WordPress Core


Ignore:
Timestamp:
06/21/2020 10:34:35 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Avoid a PHP warning when get_the_content() is called outside of the loop.

This ensures that $pages and other globals are only used after they have been set up in setup_postdata().

Follow-up to [44941].

Props tessawatkinsllc, dontdream, spacedmonkey, squarecandy, davidbaumwald, SergeyBiryukov.
Fixes #47824. See #42814.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r48060 r48114  
    283283    }
    284284
    285     if ( null === $post ) {
     285    // Use the globals if the $post parameter was not specified,
     286    // but only after they have been set up in setup_postdata().
     287    if ( null === $post && did_action( 'the_post' ) ) {
    286288        $elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' );
    287289    } else {
Note: See TracChangeset for help on using the changeset viewer.