Skip to content

[Bug]: insertFirstParagraph in AI Content Planner adds an empty paragraph on new posts with block templates #23398

Description

@burhandodhy

Prerequisites

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

When creating a new post that has a block template registered on the post type, Yoast SEO's AI Content Planner inserts an empty core/paragraph block at index 0. That block is saved with the post and appears before the template blocks.

Step-by-step reproduction instructions

Steps to reproduce

  1. Register a block template on the post post type.
add_action( 'init', function () {
	$post_type_object = get_post_type_object( 'post' );
	$post_type_object->template = [
		[
			'core/group',
			[
				'align'     => 'left',
				'className' => 'post-content',
				'metadata'  => [ 'name' => 'Post Content' ],
				'layout'    => [
					'type'           => 'constrained',
					'contentSize'    => '1140px',
					'wideSize'       => '1140px',
					'inherit'        => true,
					'justifyContent' => 'center',
				],
			],
		],
	];
}, 20 );
  1. Ensure Yoast SEO is active.
  2. Create a new post and verify that an empty paragraph block is inserted before the template.
Image

Expected results

There shouldn't be anything except the template content.

Actual results

There is an empty paragraph block before the template.

Screenshots, screen recording, code snippet

No response

Which editor is affected (or editors)

  • Block Editor
  • Gutenberg Editor
  • Elementor Editor
  • Classic Editor
  • Other (please specify in additional info)

Which browser is affected (or browsers)

  • Chrome
  • Firefox
  • Safari
  • Other (please specify in additional info)

Device you are using

No response

Operating system

No response

PHP version

No response

WordPress version

7.0

WordPress Theme

No response

Yoast SEO version

27.9

Gutenberg plugin version (if relevant)

No response

Elementor plugin version (if relevant)

No response

Classic Editor plugin version (if relevant)

No response

Relevant plugins in case of a bug

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions