wp/wp-includes/blocks/post-content.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/blocks/post-content.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/blocks/post-content.php	Tue Sep 27 16:37:53 2022 +0200
@@ -36,11 +36,21 @@
 
 	$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();
+	// Check for nextpage to display page links for paginated posts.
+	if ( has_block( 'core/nextpage' ) ) {
+		$content .= wp_link_pages( array( 'echo' => 0 ) );
+	}
+
 	/** This filter is documented in wp-includes/post-template.php */
 	$content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) );
 	unset( $seen_ids[ $post_id ] );