diff --git a/includes/collections/class-content-inserter.php b/includes/collections/class-content-inserter.php index ab8095c100..a45d097b61 100644 --- a/includes/collections/class-content-inserter.php +++ b/includes/collections/class-content-inserter.php @@ -264,7 +264,8 @@ function ( $block ) use ( $blocks_to_skip_empty ) { // Insert after the nth block. $rendered_content = ''; foreach ( $parsed_blocks as $index => $block ) { - $rendered_content .= $block['innerHTML']; + // Use render_block() so inner blocks (e.g. core/list-item children of core/list) and dynamic blocks are emitted. + $rendered_content .= render_block( $block ); // Insert after the nth block (index is 0-based). if ( $index === $nth_block - 1 ) { diff --git a/tests/unit-tests/collections/class-test-content-inserter.php b/tests/unit-tests/collections/class-test-content-inserter.php index 6bea31c0f7..544b0eb4a8 100644 --- a/tests/unit-tests/collections/class-test-content-inserter.php +++ b/tests/unit-tests/collections/class-test-content-inserter.php @@ -278,6 +278,29 @@ public function test_insert_after_nth_block() { $this->assertLessThan( $third_pos, $insert_pos, 'Inserted content should come before third paragraph.' ); } + /** + * Test insert_after_nth_block preserves inner blocks (e.g., list items). + * + * Regression: a `core/list` block stores its `
First paragraph.
\n\n\n" + . "\nSecond paragraph.
\n\n\n" + . "\n