2026年11月12日
2026年11月12日
WordPress Query Loop Block: Filters, Sorting, and Pagination
This article is a localized edition of the Japanese original. Read the Japanese original
When you want to show "a list of posts in a specific category" or "the three latest posts" in the WordPress block editor, you use the core "Query Loop" block. This article uses admin screen operations to explain the difference between inheriting from the template and a custom query, filtering by post type, category, tag, and author, sort order and number of posts, pagination and "No results" settings, and common mistakes (misconfiguration on archives and duplicate posts).
This block's option names and placement have changed across WordPress versions. The labels here are based on a typical display (as of October 2026); if they differ in your environment, look for options with similar names.
How the Query Loop Block Works
The Query Loop consists of an outer block that decides "which posts to pull" and an inner block that decides "how to display each post."
- Query Loop (outer): Holds conditions such as post type, filters, sort order, and number of posts
- Post Template (inner): The display template for one post. Inside it, you arrange blocks such as "Title," "Featured Image," "Excerpt," and "Date"
- Pagination and No results: Helper blocks placed below the list
Once you build the contents of the Post Template for one post, the same template repeats for every post that matches the conditions. The role of this block is to let you build post lists without writing code.
Insert the Block
- Open a post or page editing screen, or open a template in the Site Editor ("Appearance" → "Editor").
- Search for "Query Loop" from the "+" button and insert it.
- First, you are asked whether to choose from the provided patterns (design templates) or start blank.
Until you get used to it, choosing a pattern lets you start with the title, date, excerpt, and so on already in place. After inserting, you can adjust it by adding or removing inner blocks.
“Inherit from Template” vs. “Custom”
The most important Query Loop setting is how the posts to display are determined. In older versions this is a toggle called "Inherit query from template"; in newer versions you choose the query type from "Default" and "Custom."
Inherit from Template (Default)
This uses the post list WordPress would normally show for the page being displayed.
- On a category archive, the posts in that category
- On the search results template, the posts that match the search
- On the posts page (home), the latest posts
The number of posts follows "Blog pages show at most" in "Settings" → "Reading." On archive and search results templates, you should generally use this option.
Custom
This pulls posts using the block's own conditions. Wherever you place it, the same conditions produce the same posts. Use this for things like a "Latest Posts" section on the front page or a "News" list inside a page.
The detailed filter, sort, and count settings described below are mainly used when you choose Custom.
Main Settings
Select the Query Loop (outer) block and open the settings sidebar on the right. If an inner block is selected, choose the outer block with the parent-block selector at the left end of the toolbar or from List View.
Post Type
Besides "Posts" and "Pages," you can choose custom post types registered by plugins or themes, as long as they support being listed.
Filters
Adding items under "Filters" lets you narrow down posts by conditions.
- Categories and Tags: Type a name and select it. If you specify several, posts matching any of them are included.
- Authors: Show only posts written by specific users.
- Keyword: Filter by words contained in the title or content.
The available filters change depending on the selected post type (for example, a custom post type's own taxonomies).
Order By
Choose from newest to oldest, oldest to newest, title ascending or descending, and so on. Use them by purpose, such as "news by newest first" or "glossary by title."
Sticky Posts
You can choose how posts marked "Stick to the top of the blog" in the "Posts" editing screen are handled: "Include," "Exclude," or "Only." With "Include," sticky posts come first in the list, so an old post can appear at the top of what you meant to be a newest-first list. For a latest-posts section, "Exclude" is more likely to give you what you intended. This setting only matters when the post type is "Posts."
Items per Page, Offset, and Max Pages
- Items per page: How many posts to show at once
- Offset: How many posts to skip from the beginning
- Max pages to show: How many pages pagination lets visitors reach
Depending on the version, these are inside "Display settings" on the toolbar or in the settings sidebar.
Build the Contents of the Post Template
Inside the Post Template, put the blocks used to display one post. Commonly used blocks are:
- Title (can be made a link)
- Featured Image
- Excerpt (you can adjust the "Read more" text and the length)
- Date, categories, and author name
When you select the Post Template, you can switch between "List view" and "Grid view" on the toolbar, and in grid view you can also set the number of columns. The inner blocks are a shared template, so editing them in any one post applies the same change to all posts. You cannot change the design of just one specific post.
Pagination and “No Results”
Pagination
If the list has many posts, place "Pagination" (Query Pagination) inside the Query Loop. It adds Previous, page numbers, and Next blocks together, and you can change the wording and visibility of each individually. Pagination must be placed inside the Query Loop; it does not work if you move it outside.
No Results
Content you put inside the "No results" block is shown only when no posts match the conditions. For example, on the search results template you can write a message such as "No matching posts were found." If you put nothing there, the area is simply blank when there are zero results, and visitors cannot tell what happened.
Common Mistakes and Fixes
An Archive Shows Posts from Every Category
If "Custom" is selected on a category or tag archive template, every category you open shows the same list of posts. On archive, search results, and home templates, switch back to "Inherit from template."
Conversely, if you use inheritance in a Query Loop placed in the content of a page, that page has no main query for a post list, so you won't get the list you expected. Inside pages, use Custom.
The Same Post Appears Twice
If you place two Query Loops on the front page, such as "3 featured latest posts" and "all other posts," the same posts appear in both. Setting the offset of the second list to "3" skips the first three posts. However, combining offset with pagination can make the page breaks look shifted, so check page 2 and beyond before publishing.
If sticky posts are set to "Include," sticky posts may also appear in both lists.
The Post Count Setting Has No Effect
When inheritance is used, the number of posts is determined by the value in "Settings" → "Reading," not by the block. If changing the count on the block has no effect, check the query type.
Changes Don’t Appear on the Live Page
If you edited a template in the Site Editor, check that the template is included in what gets saved when you save. If you use a caching plugin, clear the cache before checking the display.
Using It with Classic Themes
With classic themes, you can still place a Query Loop in post or page content and in block widget areas. However, list pages such as category archives themselves are output by the theme's PHP templates, so you cannot replace them with a Query Loop. With classic themes, it's easiest to think of it as something for "post lists inside content or widgets."
Summary
- The Query Loop is a combination of an outer block that holds conditions and a "Post Template" that builds the template for one post.
- Use "Inherit from template" on templates such as archives and search results, and "Custom" in pages and front-page feature sections.
- With Custom, you can set the post type, filters by category, tag, and author, sort order, sticky posts, and count and offset.
- Place Pagination and "No results" inside the Query Loop.
- Check duplicate posts against the offset and sticky post settings, and a post count that has no effect against the query type.
- How to Use the WordPress "Latest Posts" Block
- How to Create an Archive Template with Full Site Editing
Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)