You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As raised in #24934 not all the filter options are available to in the Query Loop Block. I understand that will take time. In the meantime, it would be useful to allow developers to extend the Query Block to add their own settings.
With a new PHP filter as mentioned in #36504 would allow developers to extend the output on the front end but I could not find a way to extend the query parameter of getEntityRecords( 'postType', postType, query ) to include new parameters.
Currently, I am using the following code to add a new text field to support a new include attribute, which is a comma delimited string of IDs to test.
constaddIncludePosts=(settings,name)=>{if(name!=='core/query'){returnsettings;}return{
...settings,attributes: {
...settings.attributes,query: {
...settings.attributes.query,include: {type: 'array',default: [],},},},};};addFilter('blocks.registerBlockType','required/query-block/include-posts',addIncludePosts);/** * Override the default edit UI to include a new block inspector control for * assigning the anchor ID, if block supports anchor. * * @param {WPComponent} BlockEdit Original component. * * @return {WPComponent} Wrapped component. */constwithInspectorControl=createHigherOrderComponent((BlockEdit)=>{return(props)=>{if(props.name!=='core/query'){return<BlockEdit{ ...props}/>;}const{ query }=props.attributes;constinclude=query.include||[];return(<><BlockEdit{ ...props}/><InspectorControls><PanelBodytitle={__('Select Posts','ph-blocks')}initialOpen={true}><TextControllabel={__('Posts','ph-blocks')}value={include.join()}onChange={(value)=>{props.setAttributes({query: {
...query,include: value.split(',')}});}}/></PanelBody></InspectorControls></>);};},'withInspectorControl');addFilter('editor.BlockEdit','required/query-block/with-include-posts-control',withInspectorControl);
What is your proposed solution?
Allow the query in PostTemplateEdit to be extended.
What problem does this address?
As raised in #24934 not all the filter options are available to in the Query Loop Block. I understand that will take time. In the meantime, it would be useful to allow developers to extend the Query Block to add their own settings.
With a new PHP filter as mentioned in #36504 would allow developers to extend the output on the front end but I could not find a way to extend the
query
parameter ofgetEntityRecords( 'postType', postType, query )
to include new parameters.Currently, I am using the following code to add a new text field to support a new
include
attribute, which is a comma delimited string of IDs to test.What is your proposed solution?
Allow the query in
PostTemplateEdit
to be extended.Related Issues
The text was updated successfully, but these errors were encountered: