Skip to content

Meta fields not filtered by Query Loop post type — always uses editor's current post type #224

Description

@matiasqueroceballos

When using a Query Loop block configured with a custom post type, the "Link to dynamic meta" field selector only shows fields registered for the post type currently being edited (resolved via select('core/editor').getCurrentPostType()), not for the post type set in the Query Loop.

Steps to reproduce:

Register meta fields for a custom post type via the frblp_meta_fields filter
Create a page and add a Query Loop block configured to query convocatoria posts
Inside the Query Loop's post template, add a Paragraph block and open "Link to dynamic meta"
The field selector only shows fields for page, not for custom post type

Expected behavior:
The field selector should detect the post type configured in the nearest parent Query Loop block and show fields registered for that post type.

Actual behavior:
frontblocks-meta-fields-editor.js line ~100 uses select('core/editor').getCurrentPostType() which always returns the post type of the page being edited, ignoring the Query Loop context.

Workaround:
Register the CPT meta fields under both the CPT slug and page in the frblp_meta_fields filter so they appear in the editor. The frontend rendering works correctly because it resolves postId from $block_instance->context['postId'].

Suggested fix:
When the selected block is inside a Query Loop, read the query.postType attribute from the nearest ancestor core/query block to determine which post type's fields to display.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions