Query Loop

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.

Category:

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

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.

Documentation

Provides context. Optional. Type: Object.

{
  "queryId": "queryId",
  "query": "query",
  "displayLayout": "displayLayout"
}

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.

Documentation

{
  "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"
  },
  "displayLayout": {
    "type": "object",
    "default": {
      "type": "list"
    }
  },
  "namespace": {
    "type": "string"
  },
  "layout": {
    "type": "object"
  }
}

Block Supports

Optional. Type: Object.

A set of options that enables or disables block controls in the editor, for example gradient colors or padding.

Documentation

{
  "align": [
    "wide",
    "full"
  ],
  "html": false,
  "__experimentalLayout": true
}