WordPress Query Loops Explained: Building Dynamic Content Without Code

A Tutorials category filter selects two of three posts and displays both using the same card layout.

You publish a new tutorial and then forget to add it to the list on your homepage. A Query Loop can do that work for you. It selects matching entries and repeats one layout for each result. The next tutorial appears when it meets the rules you set.

Build two lists with this guide: a homepage section showing the three newest tutorials and a category archive showing the entries for the category being visited. The cards can look identical, but each list needs a different way of selecting results.

Separate the query from the card layout

Think of the query as the instruction “show the three newest published tutorials.” The Post Template inside the Query Loop is the card that repeats. Add a Post Title, Featured Image, and Excerpt inside it and each card reads its own entry. Type a fixed heading in that template and it repeats word for word.

The outer Query Loop controls which records appear and in what order. Its other children can include Pagination and No Results blocks. Click the outer block in List View if the sidebar shows image or typography options when you want to change the filters. The WordPress Query Loop documentation shows the block structure. For the background on entries and templates, start with how WordPress works.

WordPress List View showing the nested Post Template and the sidebar settings for order and sticky posts.
The outer Query Loop exposes ordering and filters. The nested Post Template holds the repeated blocks. This example uses the 2024 editor. Still from Exploring the Query Loop block by Kathryn Presner and Helena Artmann · CC BY-SA 4.0
ChangeSelect
Which posts are selected and in what orderOuter Query Loop
Where the title and thumbnail appear on each cardPost Template
How readers move to later resultsPagination inside the loop
What visitors see when no records matchNo Results inside the loop

Build a list of recent tutorials

Open the homepage on a staging site and add the Query Loop block. Choose a simple starting layout or start blank. Select the outer Query Loop in List View, then choose the custom query option when your editor offers a choice between the page’s default query and your own criteria. Labels can vary with the WordPress version. WordPress describes how the query settings have changed.

  1. Choose Posts as the content type, then select the Tutorials category.
  2. Order newest first and set three items per page. Review the sticky-post setting if pinned posts should never displace recent tutorials.
  3. Open the Post Template. Keep the thumbnail and title linked to the entry where appropriate. Use a meaningful excerpt and check how the grid stacks on mobile.
  4. Remove Pagination for this teaser. Add a clearly labelled link to the complete archive so readers can still find older posts.
  5. Test with four tutorials. Publish a new one with the correct term and confirm it appears, then publish an unrelated post and confirm it stays out.

If the new tutorial is missing, first check its publish status, selected term, ordering, and whether an older pinned post took a slot. If the template looks odd, leave the query alone and inspect Post Template. The number of cards and the styling of each card are separate changes.

Edit the card independently

  • Change the order of title, image and excerpt inside Post Template.
  • Test the link and a long title on a narrow viewport.

Inherit the query on a category archive

The Weddings category and the Portraits category can use the same archive template. WordPress already knows which category URL the visitor requested. Use the inherited or default query for the main list so the loop follows that category. A custom loop fixed to Weddings will keep showing Weddings entries when the visitor opens Portraits.

Custom homepage list

  • Choose Posts, Tutorials and newest first.
  • Limit the teaser to three articles.
  • A new qualifying article appears automatically.

Inherited category archive

  • Use the category from the current URL.
  • Let readers move between pages if the archive needs it.
  • Visit another category and confirm the results change.

Keep the archive title and description connected to the requested term. If you add a second loop called “Latest from the blog,” make that second loop explicitly custom. Give it a visible label so visitors know why those posts may be unrelated. For context on where archive and single-entry layouts are chosen, see the MDJ theme guide.

Check filters, pagination and empty results

Test the list with a small fixture where you know the result. Use entries of different types and terms, a future or draft entry, a missing featured image, and at least one entry beyond the first page. If you have two filters, check them together. A category filter and a sticky setting can both influence a result that looks surprising.

For the homepage, try four published tutorials, a fifth tutorial in draft, and a newer post in News. The newest three published tutorials should appear if you order by publication date and don’t make an exception for sticky posts. Then visit News. The main inherited archive should show the News post. If it shows tutorials instead, check its query setting before touching the card layout.

  • Pagination: keep navigation inside the loop it controls. Click page two and back on the public preview. If links update the wrong list, test with a single paginated loop and add the others back one by one.
  • Offset: skipping the first few results may make sense when another section features them. Recheck page boundaries and whether readers can find the skipped entries elsewhere.
  • No Results: add a plain message and a useful way forward, such as clearing a filter or visiting all tutorials. Verify the empty state with a genuinely empty selection.
  • Responsive cards: use a long title, a missing image and a narrow screen. The query can be correct while the cards are still hard to read.

Need more visual controls on a site already using Kadence? Kadence Blocks Pro* offers the Advanced Query Loop. Check the exact filters and pagination behavior on your site before switching a working archive. Start with core if you only need a short category list. For spacing or widths around the grid, see the Kadence layout guide.

Use known test records

  • Pick one entry that should match and one that should stay out.
  • Set the limit low enough to test a second page.
  • Choose a filter with no matching records to check the message.

Know when the native loop has reached its limit

The core loop can cover ordinary lists based on exposed post types and terms. Its date ordering uses the post’s publication date. A directory may need to sort on a stored event date, use criteria from a relationship, or let visitors combine filters. Write those requirements down before you choose a tool. A visual editor can configure supported options, and more advanced criteria still need a compatible plugin or code.

JetEngine Query Builder is an option if your WordPress listing already uses or needs JetEngine and must query custom fields or relationships. Make a few records with known dates and test sorting and missing values. Verify the listing integration and the portability of the field values before building the whole directory around it.

FacetWP is an option when visitors genuinely need faceted filtering across a catalogue and the listing integration is supported. Verify the listing provider and indexing requirements first. Test the filters together and confirm pagination, reset behavior, and keyboard access. A single category archive may already be enough for a small resource library.

Name the missing feature

  • Custom sorting: verify the exact field and stored format.
  • Interactive filtering: verify the listing provider and indexing.
  • Simple category list: start with the core Query Loop.

If you’re building both the grid and the visitor-facing filters from scratch, WP Grid Builder is another option. It has its own grid and facet workflow. Try one searchable list and one filter before using it across several templates. An existing listing integration may make a different approach easier to maintain.

Keep lists fast and maintainable

A small card grid can still load a lot of images or additional queries. Start with a reasonable number of items and appropriately sized thumbnails. Test the real page logged out and use the browser Network panel to check the selected image sizes. Test a page with a second loop and measure before and after adding it. With a filtered directory, try common combinations and measure both a typical result set and a broad one.

A list gives an editor the most value when its rules are predictable. Document which content type and terms feed it and what happens when a post is pinned, unpublished or recategorized. Confirm that the public cache refreshes after publishing a qualifying entry. For visitor-driven filters, check that different filter combinations produce the correct results on the public page.

  1. Test membership. Confirm an expected result appears and an unrelated one does not.
  2. Test order. Check newest, oldest, sticky or custom-field sorting against records you know.
  3. Test navigation. Follow a card, visit page two where present, and try the empty state.
  4. Test the next edit. Publish, update or recategorize one entry and confirm it reaches the right lists.

Build the homepage teaser first, then the inherited archive. When a new tutorial shows up where it belongs without an extra edit to either layout, the Query Loop is doing the work you wanted it to do.

FAQs

Launch Your WooCommerce Store the Smart Way

Skip weeks of design work and launch a professional WooCommerce store faster.

Explore the Theme

Leave a Reply

Your email address will not be published. Required fields are marked *