diff --git a/src/components/multiple-post-select.js b/src/components/multiple-post-select.js
index 95c78ff..5204493 100644
--- a/src/components/multiple-post-select.js
+++ b/src/components/multiple-post-select.js
@@ -13,10 +13,19 @@ export const MultiplePostSelect = ( { attributes, setAttributes } ) => {
const postTypes = useSelect( ( select ) =>
select( coreStore )
.getPostTypes()
- .filter( ( { viewable } ) => viewable )
- .map( ( { slug } ) => slug )
+ ?.filter( ( { viewable } ) => viewable )
+ ?.map( ( { slug } ) => slug )
);
+ if ( ! postTypes ) {
+ return (
+
+ { __( 'Loading…', 'advanced-query-loop' ) }
+
+ );
+ }
return (
{
),
] }
suggestions={ [
- ...postTypes.filter( ( type ) => type !== postType ),
+ ...postTypes?.filter( ( type ) => type !== postType ),
] }
onChange={ ( posts ) => {
// filter the tokens to remove wrong items.
setAttributes( {
query: {
...attributes.query,
- multiple_posts: posts,
+ multiple_posts: posts || [],
},
} );
} }