I'm working on a plugin that defined a custom block for the Gutenberg/Block Editor. The block shows a select
box of posts. When you select one, I create HTML with some of the selected post's fields, such as title, date, etc.
When I query my posts in the edit
method, my code correctly produces a list of pages (in my case, a custom post type named product
), but custom fields, which this post type has, are not included.
var pages = select('core').getEntityRecords('postType', 'product', { per_page: -1 });
I'm trying to find documentation on getEntityRecords
query parameters, but there seems to be none. Is it possible to include custom fields in the query? You would think this should be explained on https://wordpress.org/gutenberg/handbook/designers-developers/developers/data/data-core/#getentityrecords
My only other idea was: when the block is saved ("during" the save
method), is it possible to do another query that just selects the single post by ID and retrieves its data, maybe including custom fields? It seems I can't query anything during save.