Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/block-library/src/post-content/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ function render_block_core_post_content( $attributes, $content, $block ) {

$seen_ids[ $post_id ] = true;

// Check is needed for backward compatibility with third-party plugins
// that might rely on the `in_the_loop` check; calling `the_post` sets it to true.
if ( ! in_the_loop() && have_posts() ) {
the_post();
}

$content = get_the_content( null, false, $post_id );
// When inside the main loop, we want to use queried object
// so that `the_preview` for the current post can apply.
// We force this behavior by omitting the third argument (post ID) from the `get_the_content`.
$content = get_the_content( null, false );
/** This filter is documented in wp-includes/post-template.php */
$content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) );
unset( $seen_ids[ $post_id ] );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-title/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function render_block_core_post_title( $attributes, $content, $block ) {
}

$post_ID = $block->context['postId'];
$title = get_the_title( $post_ID );
$title = get_the_title();

if ( ! $title ) {
return '';
Expand Down