A WordPress Query Loop workflow moves from query settings to a repeated post template and a useful list for visitors

Editorial illustration; the editor panels and labels are representative, not a live WordPress dashboard.

Every time a WordPress client asks for “a section on the homepage showing our three latest case studies” or “a list of security guides at the bottom of the services page”, someone reaches for a post-grid plugin or writes a custom WP_Query shortcode. Half the time, neither is necessary. The core Query Loop block already handles focused editorial lists without adding another plugin to update or another PHP template to maintain.

The catch is that Query Loop only feels effortless once you separate two decisions in your head: what the query selects, and what each repeated card displays. Mix those two up in the Block Editor and you end up clicking around nested blocks wondering why changing one title changed all six.

Separating the query from the card template

In the Block Editor, Query Loop is a parent container (wp:query) that feeds results into a wp:post-template block. Everything inside wp:post-template repeats once per matching post; everything outside it—headings, pagination, and the no-results fallback—renders once.

That boundary matters when you open List View. Before you style anything, look at the block tree:

  • Query Loop holds the query parameters: post type, order, items per page, sticky-post handling, and taxonomy or author filters.
  • Post Template holds the card layout: Featured Image, Post Title, Post Excerpt, Post Date, or Read More.
  • Pagination and No Results sit alongside Post Template as siblings inside Query Loop.

If you accidentally drop a section heading inside Post Template, it repeats six times. If you drop a Post Title outside Post Template, it pulls the current page’s title instead of the queried posts. Keeping List View open while building saves a lot of head-scratching.

Inherit vs. custom queries on real pages

When you insert Query Loop on a normal page or landing page, the single most common trap is leaving Query Type set to Default. Default means inherit: true—it tries to inherit the main query of the surrounding template. On an archive template, that is what you want. On a static page, inheriting the page query just shows the page itself or nothing useful.

Switch Query Type to Custom (inherit: false) whenever you are curating a list on a normal page. In the underlying block markup, a focused security-guides list looks something like this:

<!-- wp:query {"queryId":4,"query":{"perPage":6,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","sticky":"exclude","inherit":false,"taxQuery":{"category":[12]}}} -->
<div class="wp-block-query">
  <!-- wp:post-template {"layout":{"type":"grid","columnCount":3}} -->
    <!-- wp:post-featured-image {"isLink":true} /-->
    <!-- wp:post-title {"isLink":true,"level":3} /-->
    <!-- wp:post-excerpt {"moreText":"Read guide"} /-->
  <!-- /wp:post-template -->

  <!-- wp:query-no-results -->
    <!-- wp:paragraph -->
    <p>No security guides are published in this section yet. Browse <a href="/blog/">all articles</a> instead.</p>
    <!-- /wp:paragraph -->
  <!-- /wp:query-no-results -->
</div>
<!-- /wp:query -->

Notice two small details in that markup that prevent real-world annoyance:

  1. "sticky":"exclude": If a site editor marks an announcement post as Sticky, a 3-column grid suddenly gets a 7th item pushed in, leaving an awkward orphan card on the next row. Excluding sticky posts keeps curated grids predictable.
  2. "isLink":true on both image and title: In several core patterns, the Post Title is linked by default while the Featured Image is not. Visitors instinctively tap thumbnails on mobile; check both blocks explicitly.

Filtering without turning tags into a mess

Start with one clear rule that an editor can explain in a sentence: “This block shows the newest six posts in the security category” or “the four latest case_study items”. Relying on five overlapping tags to curate a homepage block usually breaks the moment a writer forgets one tag or invents a plural variant.

Before building the block, I often run a quick WP-CLI check on staging to verify that the taxonomy or post type actually has enough published items with featured images and excerpts:

wp post list --post_type=post --category_name=security --post_status=publish --fields=ID,post_title,post_date

If you need something the block sidebar does not expose—like excluding the current post on a “Related Articles” block at the bottom of single posts—you do not have to abandon Query Loop. A small query_loop_block_query_vars filter in your theme or site-specific plugin lets you adjust the WP_Query arguments only when a specific queryId or CSS class is present:

add_filter( 'query_loop_block_query_vars', function ( $query, $block ) {
    if ( is_singular( 'post' ) && ! empty( $block->context['queryId'] ) && 4 === (int) $block->context['queryId'] ) {
        $query['post__not_in'] = array( get_queried_object_id() );
    }
    return $query;
}, 10, 2 );

That keeps the layout and card fields editable in the Block Editor while giving you exact server-side control over edge cases.

Pagination, empty states, and multiple loops

Only add the Pagination block when the list is meant to be browsed as a collection. On a “Latest 3 Tutorials” strip at the bottom of a service page, pagination adds clutter and creates strange URLs like ?query-4-page=2 that reload the entire page just to scroll back up to a footer widget. If you do use pagination on a page with two Query Loops, test clicking page 2 on the second loop—WordPress scopes pagination via query-{queryId}-page, so duplicate queryId values from copy-pasted blocks will paginate both lists at once.

Never delete the No Results block just because your query currently returns posts. Categories get renamed, drafts get unpublished, and seasonal event post types go empty between campaigns. A blank white gap on a landing page looks like a broken layout; a two-line wp:query-no-results message with a link to /blog/ or /contact/ turns an empty query into a graceful dead-end.

Testing the edges before publishing

Before calling a Query Loop section done, test it against the messy content editors actually publish:

  • Check a post with a 12-word title next to a post with a 3-word title inside a 3-column grid.
  • Check a post that has no Featured Image (either set a fallback in the theme or make sure the card alignment does not collapse).
  • Resize down to 375px wide to confirm the grid collapses cleanly to a single column without horizontal overflow.
  • Temporarily filter by a non-existent keyword to verify that your No Results message actually renders.

When a list needs complex joins, faceted filtering, or relevance-ranked search across thousands of entries, reach for proper PHP, custom endpoints, or a dedicated search tool. For the 80% of editorial lists that simply need “the latest items from X, styled cleanly”, core Query Loop keeps the logic visible, versionable, and free of extra plugin bloat.

For related editor workflows, see how WordPress List View helps edit long pages and how template parts reuse site structure.

Sources