diff --git a/packages/core-data/src/private-selectors.ts b/packages/core-data/src/private-selectors.ts index 31c06f4f2073d..22288c17e10a3 100644 --- a/packages/core-data/src/private-selectors.ts +++ b/packages/core-data/src/private-selectors.ts @@ -119,7 +119,7 @@ export function getRegisteredPostMeta( state: State, postType: string ) { return state.registeredPostMeta?.[ postType ] ?? {}; } -function normalizePageId( value: number | string | undefined ): string | null { +function normalizePageId( value: number | string | undefined ): number | null { if ( ! value || ! [ 'number', 'string' ].includes( typeof value ) ) { return null; } @@ -129,7 +129,11 @@ function normalizePageId( value: number | string | undefined ): string | null { return null; } - return value.toString(); + if ( typeof value === 'string' ) { + return parseInt( value, 10 ); + } + + return value; } interface SiteData { diff --git a/packages/fields/src/fields/template/template-edit.tsx b/packages/fields/src/fields/template/template-edit.tsx index 20fc05c0a4a10..3cf07b406874a 100644 --- a/packages/fields/src/fields/template/template-edit.tsx +++ b/packages/fields/src/fields/template/template-edit.tsx @@ -52,10 +52,9 @@ export const TemplateEdit = ( { select( coreStore ) ); - const isPostsPage = getPostsPageId() === postId.toString(); + const isPostsPage = getPostsPageId() === postId; const isFrontPage = - postType === 'page' && - getHomePage()?.postId === postId.toString(); + postType === 'page' && getHomePage()?.postId === postId; return { templates: allTemplates,