I am trying to select records that have a custom field value that matches a search condition but the result is always all records
To register the custom field for my post type I am using the following code
register_post_meta(
'my_post_type',
'my_data',
array(
'show_in_rest' => true,
'single' => true,
'type' => 'integer',
)
)
To query the posts:
const data = useSelect((select) => {
const metaQuery = [
{
key: 'my_data',
value: [50, 100],
compare: 'BETWEEN',
type: 'NUMERIC'
}
];
return select(coreDataStore).getEntityRecords('postType', 'my_post_type', { meta_query: metaQuery });
});
but I am always receiving all records with my custom posts and zero errors or warnings. The metadata field is presented in the results. Generated request to the server contains the meta_query part, but it is url encoded. This is probably a reason why meta_query is ignored.
What did I miss?