diff --git a/packages/block-library/src/post-content/index.php b/packages/block-library/src/post-content/index.php index 400e3068dfa0a9..7edb2cd604a719 100644 --- a/packages/block-library/src/post-content/index.php +++ b/packages/block-library/src/post-content/index.php @@ -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 ] ); diff --git a/packages/block-library/src/post-title/index.php b/packages/block-library/src/post-title/index.php index 61618939cec9dd..56302864265165 100644 --- a/packages/block-library/src/post-title/index.php +++ b/packages/block-library/src/post-title/index.php @@ -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 '';