WordPress.org

Make WordPress Core

Ticket #47824: 47824-tw.patch

File 47824-tw.patch, 1003 bytes (added by tessawatkinsllc, 21 months ago)

Patches this defect by adding an optional $post parameter to function "the_content" that passes it to the function "get_the_content" since it was added since 5.2.0., and falls back to the global $post variable so it does not break when used outside "the loop".

  • post-template.php

     
    236236 * Display the post content.
    237237 *
    238238 * @since 0.71
     239 * @since 5.3.2 Added the `$post` parameter.
    239240 *
    240241 * @param string $more_link_text Optional. Content for when there is more text.
    241242 * @param bool   $strip_teaser   Optional. Strip teaser content before the more text. Default is false.
     243 * @param WP_POST|object|int $post Optional. WP_POST instance or Post ID/object. Default is null and falls back to the global $post object.
    242244 */
    243 function the_content( $more_link_text = null, $strip_teaser = false ) {
    244         $content = get_the_content( $more_link_text, $strip_teaser );
     245function the_content( $more_link_text = null, $strip_teaser = false, $post = null ) {
     246        if( $post === null ) { global $post; }
     247        $content = get_the_content( $more_link_text, $strip_teaser, $post );
    245248
    246249        /**
    247250         * Filters the post content.