Query Loop Block
Short url: https://ewp.guide/go/be/query-loop-block
The Query Loop Block allows you to insert a list of posts. This could be a list of Pages, Posts, or even Products, if you’re using WooCommerce. Although you can add this block into your normal Page or Post content, it will be more useful adding it to your theme’s templates using the Full Site Editor.
When the Query Loop Block is first inserted, you’re prompted to choose from one of the pre-made patterns or start blank.
If you choose to start with a pre-made pattern, clicking the Choose button will show a popup window where you can select the layout pattern to use for displaying your content. Simply scroll through the available list of layout patterns and click your preferred layout to select it. You can also use the Search field at the top of the popup to search for your preferred layout.
After clicking on your preferred layout, the appropriate blocks will be inserted into your content. You will then also have access to further options on the Block Toolbar and in the Settings Sidebar.
You can also click the Start blank button after first inserting the Query Loop Block. You will then be shown a selection of layout variations to choose from. Simply select one by clicking the appropriate icon. The appropriate blocks will then be inserted into your content.
Once you’ve confirmed the layout to use for the Query Loop Block, you can use the Display settings () icon on the Block Toolbar to change the number of posts to display per page, set the offset, which is the number of posts to skip (if any), and limit the number of posts to show in the pagination.
The options in the Settings Sidebar also allow you to adjust the WordPress Query that is executed to retrieve your posts. You can select the Post type (e.g. display Posts, Pages, or even Products if you’re using WooCommerce). You can also choose the order to display your posts (e.g. Newest to oldest, Oldest to newest, or alphabetical using A > Z or Z > A), choose whether or not to include “sticky” posts, and also add filters such as Taxonomies (e.g. Categories or Tags), Authors or Keyword.
If you toggle on the Inherit query from template switch then this block will simply inherit the global query for the current template, such as an Archive or Search template.
It’s important to note that the Query Loop Block (and likewise, the Posts List Block) will insert multiple blocks within the main Query Loop Block. Before you’re able to adjust all the settings for your Query Loop, you’ll need to select the outermost Query Loop Block. Selecting this block will show all the query settings in the Block Toolbar and the Settings Sidebar. If you’re finding it difficult to select the Query Loop Block, try selecting the Block by using the Block Breadcrumbs that appear at the bottom of the page. The Breadcrumbs will appear whenever you have a Block selected, and will list all the parent blocks for the currently selected Block. You can also use the Document Overview icon () in the toolbar at the very top of the editor, to help you select the exact block you want.