💎 PREMIUM: Documentation/article/query loop block - High Quality

Query Loop block

Go back to the list of Blocks

The Query Loop block is an advanced block that allows you to display posts based on specified parameters, like a PHP loop without the code. You can think of it as a more complex and powerful Latest Posts Block. With various block patterns integrated into the block setup, you can do things like create a portfolio or a page full of your favorite recipes.

Query loop block in the editor

Anatomy of the Query Loop block

The block inspector provides a quick overview of the Query Loop block’s structure. Each part gives you access to different settings:

  • Query Loop: Configure the query parameters, such as post type or category.
  • Post Template: Choose how the content is displayed, either in a list or grid format.
  • Pagination: Select which navigation elements to include, such as next/previous buttons or page numbers.
  • No Results: Set a message to display hen a query returns no results.
image showing the query loop anatomy

Adding the Query Loop block

To add the Query Loop block to a page, click the block inserter (+) icon to open the block inserter pop-up window and choose the Query Loop block.

Adding a query loop block

You can also use the keyboard shortcut /query-loop to quickly insert a Query Loop block. 

Detailed instructions on adding blocks

Block configuration

After adding the Query Loop block you will see two options:

  • Choose
  • Start blank
Query loop block placeholder

How to choose a pattern

If you select the Choose option, you will have various pattern options. Just select one that you like, and it will be added. Each Query Loop block is made up of various nested blocks, like the Post Title block and Pagination block, so depending on which pattern you choose, nested blocks can differ. 

How to start blank

If you select the Start blank option, you’ll see four variations you can choose from. Select the one you want to use. 

Adding a blank query loop block

How to customize the appearance

There are numerous ways to customize the Query Loop block, partially because it’s made up of nested blocks that you can rearrange, add to, and more. When you customize one block in the Query Loop block, the changes will apply to all blocks of the same type. While customizing this block, it might help to use the List View found in the top toolbar. Here are some ideas for customization to get you started:

  • You can change the width of various aspects of the Query Loop block.
  • You can change the alignment of blocks within the Query Loop block.
  • You can add blocks into the Query Loop block, like Post Author or Post Excerpt.