Skip to content

fix: restore legacy Latest Posts grid columns - #85258

Open
KhushalSainS wants to merge 1 commit into
WordPress:trunkfrom
KhushalSainS:fix/latest-posts-legacy-grid-columns
Open

KhushalSainS wants to merge 1 commit into
WordPress:trunkfrom
KhushalSainS:fix/latest-posts-legacy-grid-columns

Conversation

@KhushalSainS

Copy link
Copy Markdown

What?

Closes #85242

Restores the legacy default column count for Latest Posts blocks saved before the layout-support migration. Legacy grid content such as:

<!-- wp:latest-posts {"postLayout":"grid"} /-->

now renders columns-3 again, so the front end displays a three-column grid instead of a single stacked column.

Why?

#77989 moved Latest Posts to layout support and removed postLayout and columns from block.json. The old columns attribute had "default": 3, so grid blocks that used the default column count were saved with only "postLayout":"grid", with no columns key.

Before 7.1, block registration supplied columns => 3, and the render callback output columns-3. That default no longer exists, and the server fallback now resolves to null:

$column_count = $layout['columnCount'] ?? ( $attributes['columns'] ?? null );

The editor still falls back to 3 in edit.jsx and in the block deprecation, so editors see a three-column grid while the front end renders one column. Server rendering does not run editor deprecations, and saving a post without editing the block does not migrate the stored attributes.

How?

Restore the legacy default only when no layout attribute exists:

// Legacy content did not serialize the `columns` attribute because it
// defaulted to 3. Restore that default when no layout attribute exists.
$default_column_count = empty( $layout ) ? 3 : null;
$column_count         = $layout['columnCount'] ?? ( $attributes['columns'] ?? $default_column_count );

This keeps the following behavior unchanged:

  • Legacy grid blocks with an explicit columns value keep that value.
  • Legacy list-layout blocks do not receive grid column classes.
  • Modern layout-support blocks keep their layout.columnCount behavior, including grids that intentionally omit columnCount.

No content migration or re-save is required; the fallback happens at render time. Added PHPUnit regression coverage for the legacy default, explicit column counts, list layout, migrated layout content, and modern layout grids.

Screenshots or screencast

Before After
latest-posts-before latest-posts-after

Use of AI Tools

AI assistance: Yes

Tool(s): OpenAI Codex
Used for: Reproducing the regression, checking the WordPress 7.0.4 and 7.1.3 render paths, drafting the PHP fix and PHPUnit regression tests, and drafting this PR description. I have reviewed and manually tested the code.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

👋 Welcome

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @KhushalSainS! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

🎉 Props

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @reidab.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: reidab.

Co-authored-by: KhushalSainS <khushalsains@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 21, 2026

This branch has not been deployed

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

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latest Posts: legacy grid blocks using the default column count render as a single column (regression from #77989)

1 participant