The Gutenberg Query Loop Block

written by: Jeff McNear

The “theme” tab for Gutenberg blocks contains the ability to build an archive query and place it anywhere on a page or post.

The Query Loop block allows you to build a query of any post type (including custom post types) using any/all of the following post related fields:

  • Title
  • Author
  • Date
  • Featured Image
  • Excerpt
  • Content
  • Relevant Tags
  • Relevant Categories

You are able to filter the selection by either standard taxonomies (tags & categories) but there is no provision for selection by custom taxonomy.

By default you will be given an array that shows these fields:

  • Title (linked)
  • Featured Image
  • Excerpt
  • Read More link (linked text to be set by the editor)

Alternatively you could choose the “start blank” option and select from the following options

  • Title & Date
  • Title & Excerpt
  • Title, Date & Excerpt
  • Featured Image, Date & Title

Once the starting layout is selected then there will be right column controls for:

  • Post Type
  • Order Scheme
  • Whether & how to include sticky posts
  • Filter by Category
  • Filter by Tag
  • Filter by Author
  • Filter by Keyword
  • Text & Background Color
  • An Advanced tab that allows you to specify the wrapping HTML element & attach a class to it

There are additional controls in an icon array above the block:

In the highlighted area

  • Allignment
  • Number of posts and offset
  • Whether the query will show in list or grid view (if grid view is selected the number of columns can be set in the right column)

Each element within the query loop block is selectable and can be moved around as desired … so layout control is quite straight forward!

Current downsides:

  • There is no provision for conditional language
  • Custom fields and taxonomies are not visible / avaialble
  • While you can set the number of posts to “all” there is no way to include pagination controls