Query Loop block in WordPress

Banner for article about Query Loop block in WordPress

In WordPress, the Query Loop block displays posts or custom post types based on a set of various conditions.

The block allows to customize the way it’s displayed on pages and posts. The posts or custom post types are displayed based on a set of conditions such as categories, tags, authors, etc.

Add Query Loop block

In WordPress dashboard:

  1. Open post or page in the Editor.
  2. Click on the Inserter icon to open a list of available blocks.
  3. Type Query Loop in the search field.
  4. Click on the block to add it to the content area.
  5. Once added, configure it by selecting the post types, taxonomies, and other conditions.
  6. After that, save the changes and preview the content to see how it looks on a website.

Configure Query Loop block

The main block settings is located in the Settings Sidebar, allowing to configure:

  • Color Settings
  • Settings
  • Filters

To open Settings Sidebar, select the Query Loop block from the List View. If the sidebar is not visible in the editor, it may be necessary to click the Settings icon in the top right corner.

Color Settings

Use the color settings to set the color of the text, background, and links within the Query Loop block in WordPress.

Settings

By enabling the Inherit query from template option, the default WordPress options will be used to display the content of the block.

Turn it off to customize:

  • Post type: Select whether to display posts, pages, testimonials, portfolio projects, or other custom post types that may have been added through plugins.
  • Order by: Choose the arrangement in which the block content will be listed.

Furthermore, it is possible to opt to include or exclude sticky posts or only display sticky posts.

When having Grid layout for the block, it’s also possible to use the Columns option.

Filters

To access filter options, toggle off the Inherit query from template option in Settings. Then you will be able to refine the displayed content with the filter options based on:

  • Categories
  • Tags
  • Author
  • Keywords

Remove Query Loop block

In WordPress dashboard:

  1. Open post or page in the Editor.
  2. Select the Query Loop block from the List View.
  3. Once selected, click on the Options button, represented as three vertical dots in the block toolbar, to open additional options of the block.
  4. Then, click Remove Query Loop.
  5. After that, make sure to save the changes and preview the post or page to ensure that the block has been removed correctly.