wp/wp-includes/blocks/post-content.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    34 			'';
    34 			'';
    35 	}
    35 	}
    36 
    36 
    37 	$seen_ids[ $post_id ] = true;
    37 	$seen_ids[ $post_id ] = true;
    38 
    38 
       
    39 	// Check is needed for backward compatibility with third-party plugins
       
    40 	// that might rely on the `in_the_loop` check; calling `the_post` sets it to true.
    39 	if ( ! in_the_loop() && have_posts() ) {
    41 	if ( ! in_the_loop() && have_posts() ) {
    40 		the_post();
    42 		the_post();
    41 	}
    43 	}
    42 
    44 
    43 	$content = get_the_content( null, false, $post_id );
    45 	// When inside the main loop, we want to use queried object
       
    46 	// so that `the_preview` for the current post can apply.
       
    47 	// We force this behavior by omitting the third argument (post ID) from the `get_the_content`.
       
    48 	$content = get_the_content();
       
    49 	// Check for nextpage to display page links for paginated posts.
       
    50 	if ( has_block( 'core/nextpage' ) ) {
       
    51 		$content .= wp_link_pages( array( 'echo' => 0 ) );
       
    52 	}
       
    53 
    44 	/** This filter is documented in wp-includes/post-template.php */
    54 	/** This filter is documented in wp-includes/post-template.php */
    45 	$content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) );
    55 	$content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) );
    46 	unset( $seen_ids[ $post_id ] );
    56 	unset( $seen_ids[ $post_id ] );
    47 
    57 
    48 	if ( empty( $content ) ) {
    58 	if ( empty( $content ) ) {