- { template?.title?.raw || template?.slug }
+ { template?.title || template?.slug }
{ template?.description }
diff --git a/packages/edit-post/src/components/sidebar/template/index.js b/packages/edit-post/src/components/sidebar/template/index.js
index b8308afefa857..205812819d6bc 100644
--- a/packages/edit-post/src/components/sidebar/template/index.js
+++ b/packages/edit-post/src/components/sidebar/template/index.js
@@ -79,7 +79,7 @@ export function TemplatePanel() {
panelTitle = sprintf(
/* translators: %s: template title */
__( 'Template: %s' ),
- template?.title?.raw ?? template.slug
+ template?.title ?? template.slug
);
}
diff --git a/packages/edit-post/src/store/selectors.js b/packages/edit-post/src/store/selectors.js
index a1db999ea1266..7dabddec5e90d 100644
--- a/packages/edit-post/src/store/selectors.js
+++ b/packages/edit-post/src/store/selectors.js
@@ -361,9 +361,17 @@ export const getEditedPostTemplate = createRegistrySelector(
'template'
);
if ( currentTemplate ) {
- return select( coreStore )
+ const templateWithSameSlug = select( coreStore )
.getEntityRecords( 'postType', 'wp_template' )
?.find( ( template ) => template.slug === currentTemplate );
+ if ( ! templateWithSameSlug ) {
+ return templateWithSameSlug;
+ }
+ return select( coreStore ).getEditedEntityRecord(
+ 'postType',
+ 'wp_template',
+ templateWithSameSlug.id
+ );
}
const post = select( editorStore ).getCurrentPost();