Skip to content

Allow Post Content to be edited when 'Show template' is active and Post content is nested in a Template Part#76305

Merged
talldan merged 4 commits intotrunkfrom
fix/post-content-when-in-template-part
Mar 11, 2026
Merged

Allow Post Content to be edited when 'Show template' is active and Post content is nested in a Template Part#76305
talldan merged 4 commits intotrunkfrom
fix/post-content-when-in-template-part

Conversation

@talldan
Copy link
Copy Markdown
Contributor

@talldan talldan commented Mar 9, 2026

What?

Fixes #76101

Allows blocks like Post Title/Content to be selectable when inside Template Parts and when 'Show template' is active.

Why?

From my investigation there were two causes of the bug:

  1. Template Parts: allow selection in page content focus mode #60010 disables all blocks inside template parts, even Post Title, Post Content and Featured Image. That means those block can't be interacted with.
  2. TemplateContentPanel: Don't show content blocks that are in a Query Loop #63732 introduced a getPostBlocksByName selector which is used to find blocks like Post Tile, Post Content, Featured Image and make them editable when 'Show template' is active. The memoization of this selector means it doesn't recompute when controlled blocks like template parts update (because getBlocks itself doesn't, the function has a note that mentions this.), so this selector often doesn't return the post content blocks that are within template parts.

After solving those a third issue was present:

  1. Even after the above two fixes, there's another problem. The pattern editing changes apply contentOnly mode to template parts and restricts what can be inserted into post content. This doesn't really make sense since the 'Show template' option is still supposed to be a full post/page editor, but with the template shown. A user should have full post/page editing functionality.

How?

  1. Avoids setting blockEditingMode: disable on blocks like Post Content, ensure that the default block editing mode is set instead.
  2. Remove the memoization of getPostBlocksByName to ensure blocks can be selected.
  3. When 'Show template' is active, template parts are no longer considered contentOnly sections. This isn't a simple change, the 'Show template' mode is implemented in the Editor package while contentOnly sections are in the Block Editor package. To solve this we introduce a disableContentOnlyForTemplateParts editor setting that the editor package sets to true whenever renderingMode === 'template-locked'. This setting is similar to the one introduced for unsynced patterns in Block Editor: Allow disabling content-only editing for unsynced patterns #75457

Testing Instructions

  1. Create a template part that has Post Content nested within it
  2. Add this template part into a Single Post template
  3. Edit a post that uses the template
  4. Enable 'Show template' from the document settings
  5. Try editing the post content
Before After

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Block] Template Part Affects the Template Parts Block [Feature] Page Content Focus Ability to toggle between focusing on editing the page and editing the template in the site editor. [Package] Block editor /packages/block-editor [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show Template with Template Parts, unable to select

4 participants