diff --git a/mailpoet/assets/js/src/email-editor/engine/store/selectors.ts b/mailpoet/assets/js/src/email-editor/engine/store/selectors.ts index 1d49e7378d..77f96c9a0b 100644 --- a/mailpoet/assets/js/src/email-editor/engine/store/selectors.ts +++ b/mailpoet/assets/js/src/email-editor/engine/store/selectors.ts @@ -196,10 +196,18 @@ export const getCurrentTemplate = createRegistrySelector((select) => () => { */ export const getEmailTemplates = createRegistrySelector( (select) => () => - select(coreDataStore).getEntityRecords('postType', 'wp_template', { - per_page: -1, - post_type: 'mailpoet_email', - }), + select(coreDataStore) + .getEntityRecords('postType', 'wp_template', { + per_page: -1, + post_type: 'mailpoet_email', + }) + // We still need to filter the templates because, in some cases, the API also returns custom templates + // ignoring the post_type filter in the query + ?.filter( + (template) => + // @ts-expect-error Missing property in type + template.theme === 'mailpoet/mailpoet', + ), ); export function getEmailPostId(state: State): number {