From d16b60357a2e9990205e7423fa67ebb4c1d58b0f Mon Sep 17 00:00:00 2001 From: ramon Date: Fri, 6 Dec 2024 19:54:55 +1100 Subject: [PATCH 1/2] WordPress will try to create a slug from the title. WordPress will also look for a corresponding page- template that matches the slug name. Therefore if a page template exists with the name page-no-title, WordPress will apply that template to any page with that unique slug. This causes unexpected template assigment. TT4 and TT5 most notably. It's also inconsistent since subsequent untitled pages created in the site editor will use the default template, slugs being unique. Anyway, let's just use WordPress's default behavior, which is to create a unique slug using wp_unique_post_slug if none exists. --- packages/edit-site/src/components/add-new-post/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/edit-site/src/components/add-new-post/index.js b/packages/edit-site/src/components/add-new-post/index.js index 04e286e3967a44..ca0c7e1cd8e988 100644 --- a/packages/edit-site/src/components/add-new-post/index.js +++ b/packages/edit-site/src/components/add-new-post/index.js @@ -45,7 +45,6 @@ export default function AddNewPostModal( { postType, onSave, onClose } ) { { status: 'draft', title, - slug: title || __( 'No title' ), content: !! postTypeObject.template && postTypeObject.template.length From e0c23de4de6a5d8fb92d98f0d81a5ff803e01337 Mon Sep 17 00:00:00 2001 From: ramon Date: Sat, 7 Dec 2024 10:01:36 +1100 Subject: [PATCH 2/2] Turns out that the core data reducers needs a slug key (I think) --- packages/edit-site/src/components/add-new-post/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/edit-site/src/components/add-new-post/index.js b/packages/edit-site/src/components/add-new-post/index.js index ca0c7e1cd8e988..a30f5995aab6fa 100644 --- a/packages/edit-site/src/components/add-new-post/index.js +++ b/packages/edit-site/src/components/add-new-post/index.js @@ -45,6 +45,7 @@ export default function AddNewPostModal( { postType, onSave, onClose } ) { { status: 'draft', title, + slug: title ?? undefined, content: !! postTypeObject.template && postTypeObject.template.length