An advanced block that allows displaying post types based on different query parameters and visual configurations.
This block is available in the latest version of WordPress and does not require the Gutenberg plugin.
Last updated
Block variations: Posts List: Display a list of your most recent posts, excluding sticky posts. Title & Date. Title & Excerpt. Title, Date, & Excerpt. Image, Date, & Title.
For developers
Block Grammar & Markup
<!-- wp:query -->
<div class="wp-block-query"></div>
<!-- /wp:query -->
Context
Context is used to pass values from a block to a descendant block; for example, a query and post template passing the query ID to the inner blocks.
Provides context. Optional. Type: Object.
{
"queryId": "queryId",
"query": "query",
"displayLayout": "displayLayout",
"enhancedPagination": "enhancedPagination"
}
Block Attributes
Optional. Type: Object.
Attributes provide the structured data needs of a block. They can exist in different forms when they are serialized, but they are declared together under a common interface.
{
"queryId": {
"type": "number"
},
"query": {
"type": "object",
"default": {
"perPage": null,
"pages": 0,
"offset": 0,
"postType": "post",
"order": "desc",
"orderBy": "date",
"author": "",
"search": "",
"exclude": [],
"sticky": "",
"inherit": true,
"taxQuery": null,
"parents": []
}
},
"tagName": {
"type": "string",
"default": "div"
},
"namespace": {
"type": "string"
},
"enhancedPagination": {
"type": "boolean",
"default": false
}
}
Block Supports
Optional. Type: Object.
A set of options that enables or disables block controls in the editor, for example gradient colors or padding.
{
"align": [
"wide",
"full"
],
"html": false,
"layout": true,
"interactivity": true
}