[wp-trac] [WordPress Trac] #42958: create callers for loop functions to accept post id
WordPress Trac
noreply at wordpress.org
Tue Nov 17 07:06:03 UTC 2020
#42958: create callers for loop functions to accept post id
-------------------------+------------------------------
Reporter: tazotodua | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: 2nd-opinion | Focuses:
-------------------------+------------------------------
Comment (by sabernhardt):
The output with the `$post` parameter is not always the same as it would
be for the post within the loop, yet the functions below worked for me
outside the loop. (Most needed `$post = 42` instead of just the post ID
integer.)
{{{
<?php echo get_the_content( $post = 42 ); // output includes block editor
comments ?>
<?php the_content( $post = 42 ); // output without HTML comments ?>
<?php echo get_the_title( 42 ); // this correctly gave the post title,
though the_title($post=42) printed both post ID and title ?>
<?php echo get_the_post_thumbnail( 42 ); // image output may be adjusted
to content width ?>
<?php the_post_thumbnail( $post = 42 ); // image output at full width ?>
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42958#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list