[wp-trac] [WordPress Trac] #44788: the_content() strange behavior - we can't change global "post_content" from "$post->post_content"
WordPress Trac
noreply at wordpress.org
Tue Aug 14 23:49:46 UTC 2018
#44788: the_content() strange behavior - we can't change global "post_content" from
"$post->post_content"
-------------------------------+----------------------
Reporter: Tkama | Owner: (none)
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Posts, Post Types | Version: 4.9.8
Severity: normal | Resolution: invalid
Keywords: | Focuses:
-------------------------------+----------------------
Changes (by SergeyBiryukov):
* status: new => closed
* type: feature request => enhancement
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
To clarify a bit more, setting `$post->post_content` does affect the
`$post` global, however that's not the value used in `get_the_content()`,
at least not directly.
The function takes `$content` [source:tags/4.9.8/src/wp-includes/post-
template.php?marks=287,289,295#L286 from the $pages global], which is set
up in [source:tags/4.9.8/src/wp-includes/class-wp-
query.php?marks=4007,4009#L3996 WP_Query::setup_postdata] earlier.
It's not quite clear when exactly your snippet runs, but it should work if
you add `setup_postdata( $post )` after changing `$post->post_content`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44788#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list