Almost every real website needs a list that builds itself. A row of latest articles, a related posts strip under a post, a grid of team members, a list of product categories, a directory of authors. In plain HTML you would copy and paste the same card ten times and edit each one by hand. In WordPress, the list should come from the database, so that when someone publishes a post or adds a team member, the page updates without anyone touching the layout. In Bricks, the tool for that is the query loop.
The idea that makes everything else easy is this: a query loop is a repeater. You design one item, once, and tell Bricks where the data comes from. Bricks runs the query, then renders your item once for every result, and inside each repetition the dynamic data tags read from the result currently being drawn instead of from the page. Almost every question people ask about loops, from “why does my title show the page title on every card” to “why did my whole grid repeat”, is a question about which element repeats and what the current result is at that point. Once you hold that picture, the controls fall into place.
This guide builds the picture from zero. It begins with what a loop is and how one iteration works, then which elements can loop and how to switch a loop on. It explains the five query types and how to choose between them, and then goes through the controls of the posts query one by one, with the terms and users equivalents beside them. After that it covers dynamic data inside a loop, followed by two worked examples (a related posts section and an author list), the terms query for category lists, the Query editor with PHP (what it is and how to use it safely), pagination and the archive main query, empty states, and the mistakes that cause the most confusion, written as symptoms and causes.
A few boundaries. This is a general guide, written from the public Bricks documentation and from how WordPress queries work. It is not a hands-on test report and contains no benchmarks. Bricks changes between versions, and some controls were added over time, so where a control or tag is version sensitive the text tells you to check the Bricks Academy for the release you have. Code samples are complete and say where they go. The PHP examples use WordPress core functions and the Bricks filters documented for query loops. Treat any PHP in the Query editor, or in a theme file, as code that can break a live site: write it on a staging copy first, and keep it small.
Key points
- A query loop is a repeater: you design one item, Bricks runs a query, and the item renders once per result with dynamic data reading the current result.
- Layout elements such as Container, Section, Block and Div can loop, and the element with Use Query Loop switched on is the one that repeats, so put it on the card, not the grid.
- The posts, terms and users query types map to WP_Query, WP_Term_Query and WP_User_Query, and the API and array types cover data from outside the database.
- Dynamic data tags resolve against the innermost loop, and tags placed outside the loop element, or tags that do not fit the query type, read the page instead.
- Related posts, author lists and category lists are the same pattern with different query types, and a small PHP filter or Query editor fills the gaps the interface leaves.
- Set a realistic number per page, link the Pagination element to the right query, and mark only one loop as the main query on an archive.
- Always design the empty state, because a loop with no results is a normal case, not an error.
A loop is a repeater with a changing context
Start with the smallest possible picture. You place a card on the page: an image, a heading, a line of text. You tell Bricks that this card should repeat, and what to repeat it for. Bricks then asks WordPress for a list of things, such as the four latest posts, and for each thing it draws a copy of your card. In the first copy the heading shows the first post’s title. In the second copy it shows the second post’s title. The card is the template. The list is the data. The loop is the glue.
The word that matters is context. Normally a dynamic data tag such as the post title reads from the page that is being viewed. Inside a loop, Bricks switches the current object for each repetition, so the same tag reads from the result being drawn. Bricks describes it this way: dynamic data uses the current loop result, and in a nested loop the inner result becomes the current one for the elements inside that loop. This is why one card design can show many different titles, and it is also the root of most loop bugs, because a tag only gets the loop’s context when it sits inside the looping element.
Here is one iteration, step by step. Bricks reads the query settings from the looping element and builds the query. WordPress runs it and returns a list of results, which for a posts query are posts, for a terms query are terms and for a users query are users. Bricks then walks the list. For each result it makes that result the current object, renders the looping element with all its children, evaluates each dynamic tag against the current object, and writes the HTML. When the list is exhausted it closes the loop, and if the list was empty it shows the no results content instead.
Bricks also wraps loop output in HTML comments, such as a loop-start marker. They look like debris, but the documentation says they are essential for AJAX pagination, query filters, load more and infinite scroll to work, so no tool in your stack should strip them. Remember that if you ever minify your HTML aggressively.
One more fact shapes how you design. Each loop is identified by the element ID of the looping element, which on the frontend is usually the six-character Bricks ID. That ID is how pagination, filters and live search find the loop they control, and how a PHP filter can target one specific loop. Give loop elements descriptive names in the structure panel, as the Bricks documentation suggests, so you can find them later.
One query loop, step by step
- Read settingsThe looping element holds the query type and its controls.
- Run the queryWordPress returns posts, terms or users, or Bricks reads an array or API.
- Pick the next resultBricks sets it as the current object for this repetition.
- Render the elementThe looping element and all its children are drawn once.
- Resolve the tagsDynamic data reads the current result, not the page.
- Repeat or finishMore results go back to step three; an empty list shows the empty state.

Where loops live: which elements can repeat
The query loop builder is available on the layout elements: Container, Section, Block and Div. It is also available on the classic Accordion and Slider elements, where each result becomes an item. The Map element has its own loop controls for dynamic addresses, and the nestable elements such as Accordion (Nestable), Tabs (Nestable) and Slider (Nestable) use their own child repeaters, so they do not expose the same full query loop control. If you use a nestable element, check its page in the Bricks documentation for how it takes dynamic items.
To switch a loop on, select a layout element, find the Use Query Loop setting and enable it. A Query control appears, shown with a loop icon, and opening it reveals the query settings. From that moment the element is a repeater: everything inside it repeats as often as there are results, and the element itself repeats too. This detail is where beginners trip, so say it plainly. The element that has the loop switched on is the thing that gets repeated. If you turn the loop on for the wrapper that holds your whole grid, then the grid repeats. You want the loop on the card, the element that should appear once per result.
A good structure looks like this: an outer Div or Block that acts as the grid or list wrapper, with no loop, containing a single Block or Div that has Use Query Loop switched on and holds the image, heading and text. The wrapper renders once, and the card renders for each result. The same idea applies to semantic lists. For an unordered list, the Bricks documentation uses a Div with the HTML tag set to ul and no loop, and a child Div with the tag set to li and the loop enabled. It recommends Div rather than Block here, because Block has default flex layout styles that can remove the list markers, whereas Div has no default layout styles.
This is the HTML that structure produces on the frontend, with three results, followed by CSS for it. The ul is written once and the li is the element that repeats:
<ul class="post-list">
<li class="post-list__item"><a href="/how-to-read-a-request-waterfall/">How to read a request waterfall</a></li>
<li class="post-list__item"><a href="/choosing-a-caching-layer/">Choosing a caching layer</a></li>
<li class="post-list__item"><a href="/fonts-that-do-not-shift-your-layout/">Fonts that do not shift your layout</a></li>
</ul>
.post-list {
display: grid;
gap: 0.5rem;
margin: 0;
padding: 0;
list-style: none;
}
.post-list__item {
padding: 0.75rem 1rem;
border: 1px solid #d5dae1;
border-radius: 8px;
}
In the builder, the list container is a Div with the HTML tag ul and no loop. The child Div has the tag li and Use Query Loop switched on, and inside it sits a heading or text element with a dynamic link and the post title tag. Each result then produces one li inside the single ul, which is valid list markup that assistive technology can announce as a list. In the CSS, the container is a grid with a gap, so you control spacing without margins on each item, and the reset removes the browser’s default indent and bullets. One accessibility detail is worth knowing. When a list has its markers removed, some browser and screen reader combinations, notably Safari with VoiceOver, have stopped announcing it as a list. If the list matters to the reader, add a role attribute with the value list to the container, using the element’s Attributes setting under the Style tab, and test with the screen reader you care about. The figure after this section shows the most common way to get the structure wrong.
Two small habits help. Rename the looping element in the structure panel to something meaningful, such as “Related posts loop”, since the loop’s identity and its ID matter later. And while you build, keep the canvas honest: the builder can limit how many results a loop shows on the canvas to keep editing fast, so a loop that looks short in the builder may be longer on the frontend. Always check a real page.
Loops also work inside components and with components, which is useful for a reusable card. A component can be used inside a loop, and a component can carry its own loop. The detail of how to build that belongs to a guide on components, but it is worth knowing early that the pieces fit together.

Choosing the query type
When you open the Query control, the first decision is the type. Bricks supports five built-in types: posts, terms, users, API and array. Pick the type by the thing you are listing, not by how it will look.
Posts runs a WordPress post query, and it is the default. Use it for posts, pages, media files and any registered public custom post type, which means articles, products, events, team members stored as posts and attachments. If the content has its own editor screen in WordPress, it is probably a post type.
Terms runs a term query. Use it to list the terms of a taxonomy: categories, tags, product categories, or your own taxonomies such as regions or topics. It is the right tool for a category grid or a topic index, where each item is a term with its own archive page.
Users runs a user query. Use it to list site users, such as blog authors, community members, or team members who are stored as users. Filter by role to keep the list to the people you intend to show.
API renders items from an external JSON API. You configure the request in a settings popup: the address, method, authorisation, headers, parameters, response path, cache duration and pagination. It is for data that does not live in WordPress. Array loops through a PHP or JSON-style array, which is handy for the output of a custom function or for nested arrays inside an API response. These last two have limits: the documentation states that API loops do not support query filters or live search, and the array and API types use their own settings instead of the standard post controls. A separate guide covers external data in depth.
There is a trap in how people choose. Because a team can be modelled as users or as a custom post type, there are two ways to build the same page. Users suit people who need accounts and author archives. A post type suits content that editors manage like pages, with its own fields, images and ordering, and that is not tied to login accounts. The query follows the model, so choose the model first.
Finally, a note on relationships. Plugins that add relationship or repeater fields can feed the loop as well. The Bricks documentation says the relationship and repeater field types of the popular custom field plugins are available inside the query loop builder, so you can loop over the output of such a field and render its sub-fields as dynamic data. Where such a field gives you a list of posts, a posts query is usually the cleaner choice, since it keeps all the post tags and controls.
Which query type fits?
The posts query controls, one by one
The posts query is where you will spend most of your time, so it is worth knowing every control and what it does. The list below follows the Bricks documentation for the current Query control, and it names the controls as they are labelled there. Some were added in later versions, so if one is missing, check the Academy for your release.
- Post type. One or several types, with posts as the default. Selecting Media gives you attachments, with an extra control for the mime type.
- Order by and Order. Order by published date, modified date, title, ID, author, comment count, relevance, menu order or random. The default is published date, descending. Newer versions allow several ordering criteria in sequence. When you paginate and order by something that can repeat, such as a price, add ID as a secondary criterion so a post does not appear on two pages.
- Posts Per Page. How many results to show per page. The default is the number set in WordPress under Settings, Reading, for blog pages show at most. Always set this deliberately.
- Offset. How many results to skip. It is useful for a “featured first item, then a list” layout built from two loops.
- Ignore Sticky Posts. Turn it on if you do not want sticky posts moved to the front.
- Disable Query Merge. On archive and search templates Bricks merges loops with the page’s own query by default. Turn this on for any loop that is not the main listing, especially in headers and footers.
- Child Of. Returns only children of the given parent ID, useful for child pages.
- Include and Exclude. Add or remove specific posts. In current versions these accept dynamic data, so IDs can come from a custom field or the page context. There are matching author include and exclude controls in newer versions.
- Exclude Current Post. Removes the post currently being viewed. This is the control that makes related posts possible.
- Terms Include/Exclude, Taxonomy Query and Relation. Filter by term. The relation says whether multiple taxonomy rules combine as OR (inclusive) or AND (exclusive).
- Meta Query and Relation. Filter by custom field values, with the same OR and AND choice. A meta query compares the value stored in the database, not what a field plugin displays, so a date stored in one format must be compared in that format.
- Is main query (Archive, Search). On archive and search templates, mark the loop that is the main listing, so pagination does not give a 404. Only one loop per page should be the main query.
The performance controls (No Found Rows and the options to skip meta and term cache updates) deserve their own treatment, and they are covered in a separate Bricks performance guide. The short version is that skipping the count query is safe when you do not paginate, and skipping the caches is safe only when the loop outputs nothing from meta or terms.
The terms and users queries use the same ideas with different controls, as the figure shows. Terms have Taxonomies, a Number, Parent and Child of for hierarchy, Childless and Show empty. Users have Roles and a Number. Both can use a meta query, both have a Disable Query Merge toggle, and both have a No Results text, which you will meet again in the empty states section.
Posts, terms and users queries side by side
| Posts | Terms | Users | |
|---|---|---|---|
| Runs on | WP_Query | WP_Term_Query | WP_User_Query |
| How many | Posts Per Page | Number | Number |
| Order by | Date, title, ID, menu order, random | ID, name, parent, count, include list | ID, name, registered date, post count |
| Narrow by | Post type, terms, taxonomy, meta, authors | Taxonomies, parent, child of, meta | Roles, meta |
| Special controls | Exclude Current Post, Ignore Sticky | Current post term, Show empty | Current post author |
Dynamic data inside the loop
A loop without dynamic data is just a repeated block of identical text. Dynamic data is what makes each repetition different. You insert it by typing an opening curly brace in a text setting, which opens the picker, or by clicking the bolt icon next to a setting, and non-text settings such as images and links have a dynamic data dropdown.
The tags you use depend on the query type, because the current object is a post, a term or a user. The Bricks documentation lists them in groups. For a posts loop: {post_title}, {post_url}, {post_date}, {post_excerpt}, {featured_image}, {post_id}, the taxonomy tags in the form {post_terms_category}, and author tags such as {author_name} and {author_archive_url}. For a terms loop: {term_name}, {term_url}, {term_description}, {term_count}, {term_id} and {term_meta:your_key}. For a users loop, the user profile tags such as {wp_user_display_name}, {wp_user_picture} and {wp_user_description}, which describe the user context. Custom fields you created with the WordPress native custom fields use the cf_ prefix, as in {cf_phone_number}, and fields from the supported custom field plugins appear in the picker.
Tags accept filters after a colon. {post_title:link} renders the title as a link to the post, {post_excerpt:20} limits the excerpt to twenty words, and {featured_image:medium_large} chooses an image size. These make a card from three elements possible: an Image set to the featured image, a Heading set to the linked title, and a Text with the trimmed excerpt. There are also tags that belong to the loop itself. {query_loop_index} returns the position of the current item, starting at zero unless you pass the argument that starts it at another number, and {query_results_count} returns how many results there are. Outside the loop, the count tag needs the query ID passed to it.
Now the rules that prevent most bugs.
- The tag must sit inside the looping element. A tag placed outside reads the page, not the loop. If every card shows the page title, the tag is outside, or the loop is switched on at the wrong level.
- The tag must fit the query type. A term tag in a posts loop has no term to read. If a tag shows nothing, check that it is meant for this type.
- Media loops are special. When a posts loop queries Media, the items are attachments. The documentation says to use
{post_id}for the image source and{post_title}for the image title, and to avoid{featured_image}because it does not apply there. - There is no parent-loop syntax. Inside a nested loop the tags read the inner result, and Bricks does not provide a way to read the parent result from inner markup. Keep parent values outside the inner loop, or use custom PHP or a custom tag. A separate guide covers nested loops.
One last tip: when a tag is not behaving, temporarily drop the plain tag into a text element inside the loop and check what it returns before you wire it into an image or a link. Debugging a text output is far faster than debugging a broken image source.
Worked example: a related posts section
The brief: under every article, show three other articles that share a category, with an image, the title, the date and a short excerpt. There are two routes, and the right one depends on how much control you need.
Route one: the Related Posts element. Bricks ships a Related Posts element that shows posts related to the current one by shared taxonomies. Its documented settings include the post type, a maximum number of related posts (default three), the order and order by (default random), the common taxonomies posts must share (default category and tag), the posts per row, which fields to show through a repeater (defaults include the linked title, date and a trimmed excerpt) and image options. If that covers your design, use it, because it is the least code. Check the element’s page in the Academy for the exact controls in your version.
Route two: a query loop you control. Use this when the layout does not fit the element or you need exact rules. Build it like this:
- In a Single post template, add a heading (“Keep reading”) and below it a Div as the grid wrapper, with no loop.
- Inside, add a Block for the card and switch on Use Query Loop. Name it “Related posts loop”.
- In the Query control, keep the type as posts and the post type as posts. Set Posts Per Page to three, order by published date, and switch on Exclude Current Post and Disable Query Merge. If the loop has no pagination, also switch on No Found Rows.
- Inside the card, add an Image with the featured image tag (for example
{featured_image:medium_large}), a Heading set to the linked title tag, a Text for the date tag, and a Text for the trimmed excerpt tag.
That gets you three other posts, but not yet related ones. Check whether the taxonomy query in your version can take the current post’s own terms. If it cannot, use a small filter that Bricks provides for exactly this kind of rule. It runs before the query and lets you change the query arguments for one loop. Add it to a child theme or a small site plugin:
add_filter( 'bricks/posts/query_vars', function ( $query_vars, $settings, $element_id, $element_name ) {
// Replace abc123 with the six-character ID of your related posts loop.
if ( 'abc123' !== $element_id || ! is_singular( 'post' ) ) {
return $query_vars;
}
$category_ids = array_map( 'absint', wp_get_post_categories( get_queried_object_id() ) );
if ( $category_ids ) {
$query_vars['category__in'] = $category_ids;
} else {
// No categories: return nothing so the empty state shows.
$query_vars['post__in'] = array( 0 );
}
return $query_vars;
}, 10, 4 );
The callback receives the query arguments, the element settings, the loop’s element ID and the element name, and it must return the arguments. The first condition makes the filter touch only your loop and only on single posts, so nothing else on the site changes. wp_get_post_categories returns the current post’s category IDs, which absint cleans. If there are categories, category__in restricts the loop to posts in any of them. If there are none, setting post__in to zero makes the loop return nothing, instead of falling back to every post. Find the element ID by right-clicking the loop element and copying its query ID, or by reading the six-character ID Bricks shows for the element.
The grid wrapper is the one element in this example that does not loop, so it is where the responsive layout lives. Select the wrapper and add this to its custom CSS, where Bricks replaces %root% with the selector of the element you are editing:
%root% {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
gap: 1rem;
}
Each repetition of the card becomes one grid item. auto-fill with minmax(min(100%, 16rem), 1fr) asks the browser to fit as many columns of at least sixteen rem as the wrapper allows, so the same rule gives three columns on a wide screen, two on a tablet and one on a phone, with no breakpoint settings. The inner min(100%, 16rem) stops a column from being wider than a very narrow container, which would otherwise cause sideways scrolling. If you want exactly three columns on desktop, use repeat(3, minmax(0, 1fr)) and change it at the breakpoints you use. Because the rule sits on the wrapper and not on the card, it keeps working if the number of results changes.
Note that the builder canvas renders the element in its own request, so the preview may show unrelated posts or none. Judge the result on the frontend of a real post. The figure shows how the finished section looks as plain HTML and CSS.

The Query editor (PHP), query filters and global queries, used safely
The interface covers the common cases. When it does not, Bricks gives you two PHP routes and one reuse feature. Knowing the difference, and the risk of each, keeps you out of trouble.
The Query editor (PHP). In the Query control you can switch on the Query editor (PHP) option, which shows a code editor. You write PHP that returns an array of WordPress query arguments, and Bricks uses it for the loop. The editor supports dynamic data tags, so you can pass values from the page or a custom field into the arguments. For example, this returns related posts by category, as the body of the editor (check the Academy page for the exact format your version expects):
$post_id = get_queried_object_id();
$category_ids = array_map( 'absint', wp_get_post_categories( $post_id ) );
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'post__not_in' => array( $post_id ),
'ignore_sticky_posts' => true,
'no_found_rows' => true,
);
if ( $category_ids ) {
$args['category__in'] = $category_ids;
} else {
// No categories: return nothing so the empty state shows.
$args['post__in'] = array( 0 );
}
return $args;
The code reads the current post, collects its category IDs, builds a standard argument array, restricts it to those categories when there are any, and returns the array. Notice what it does not do: it does not print anything and does not write to the database. The Bricks documentation says to keep the returned array focused on query arguments, and not to echo output or run unrelated database writes inside a Query editor.
This feature runs PHP that is stored in the database, so Bricks protects it with layers. Code execution must be enabled in the Bricks settings under Custom code, the user needs the Bricks execute code capability, and the code must carry a valid signature, because Bricks signs Query editor code and will not run it if the signature is missing or invalid. In the builder, unsigned code is highlighted and there is a Sign code action. After signing, save the page so code and signature are stored together. Treat these as security controls, not obstacles: enable code execution only for people you trust, and leave it off on sites where nobody needs it.
Query filters in PHP. The alternative is a filter in a child theme or small site plugin, such as the related posts filter earlier. Bricks documents one filter per query type: bricks/posts/query_vars, bricks/terms/query_vars and bricks/users/query_vars, each receiving the query arguments, the element settings, the element ID and the element name. Code in a theme file lives in version control, is reviewed with your other code, and does not depend on signatures, which is why it is the better home for anything important or long-lived. The query editor is best for quick, one-off rules by people who already have the right access.
Global queries. If several loops need the same query, Bricks lets you save a loop’s query once and reuse it. The loop then stores a reference to the global query, so editing the global query updates every loop that uses it. Disconnecting copies the current settings back into the loop, and deleting the global data leaves referencing loops without the saved settings. Global queries can hold regular controls, API settings and even Query editor code. They appeared in later versions and are managed in the Query Manager, so check the Academy for your release. Use clear names, such as “Latest three properties”, not “Query 1”.
Worked example: an author list with a users query
The brief: a page that lists the site’s authors, each with a photo, a name, a short bio and a link to their articles. This is a users query, and the structure is the same as the related posts example.
- Add a Div as the grid wrapper, with no loop, and a Block inside it as the card.
- On the card, switch on Use Query Loop, set the type to users, and in Roles pick the role your authors have. The roles control keeps the list to the people you intend to show. Set Number to a sensible limit and choose an order, for example by name, or by post count if you want the busiest authors first.
- Inside the card, add an Image whose source is the user picture tag, a Heading with the user display name tag, a Text with the user description tag, and a Button or link that points to the author’s page with the user author URL tag.
Three design points matter more than the clicks.
Show only what you mean to expose. A users loop makes personal data one tag away. The documentation lists tags for the email address, the login name and more, and it is easy to drop one in during testing and forget it. Use display name, bio and picture. Do not show email addresses, and avoid the login name, because that is the credential half of someone’s account and listing it makes guessing easier. Also decide whether every user with the role should be public, since a former contributor might still hold it.
Do not link to empty archives. An author who has no published posts gets an empty author archive, so the link leads nowhere useful. WordPress can restrict a user query to users who have published posts, and the Bricks users filter lets you add that argument. Replace the example ID with your loop’s ID:
add_filter( 'bricks/users/query_vars', function ( $query_vars, $settings, $element_id, $element_name ) {
// Replace def456 with the six-character ID of your author list loop.
if ( 'def456' !== $element_id ) {
return $query_vars;
}
// Only users who have published at least one post.
$query_vars['has_published_posts'] = array( 'post' );
return $query_vars;
}, 10, 4 );
The callback checks the element ID so only the author list is affected, then adds the WordPress user query argument that limits results to users with published posts of the listed post types, and returns the array. Put it in a child theme or site plugin.
Plan for the missing photo. Not every user has a picture. Decide what the card looks like without one, and check that the layout does not collapse. The same applies to an empty bio. If a tag can be empty, design the card so empty is a normal state, not a broken one. The figure shows how the finished list looks as plain HTML and CSS.

Terms queries: category lists, topic indexes and the current post’s terms
A terms query lists taxonomy terms instead of posts, and it follows the same repeater pattern with a different set of controls. The Bricks documentation lists them: Taxonomies, Order by, Order, Number, Offset, Parent, Child of, Childless, Disable Query Merge, Terms Include and Exclude, Show empty, a Meta Query with its relation, No Results text and a Current post term toggle.
Here is a category grid for a shop or a blog. Add a Div wrapper with no loop and, inside it, a Block that is the item with Use Query Loop switched on. In the Query control set the type to terms and choose the taxonomy, for example the category taxonomy or a product category taxonomy. Set Number to cap the list, because the default is based on the Reading setting for blog pages and zero means show all. Choose an order, such as by count, descending, to put the busiest categories first, and leave Show empty off so you do not list categories with nothing in them.
Inside the item you can show the term name, the term description, the term count and any term meta. To make the whole item clickable, set the item’s HTML tag to a link and set the link type to dynamic data, then pick the term archive URL tag. The Bricks documentation uses exactly this pattern for a list of product categories. If your category has an image stored in term meta, the term meta tag with your key supplies it, and WooCommerce product categories have their own image tag.
Hierarchy controls. Parent returns the direct children of a given term ID, while Child of returns all descendants. The documentation illustrates this with a clothing hierarchy: a given parent can return only the direct child, while Child of also returns deeper levels. Childless limits results to terms that have no children, and it has no effect on non-hierarchical taxonomies such as tags. If you build a two-level navigation, loop the parents first and treat the deeper levels in a separate loop, remembering that tags inside an inner loop read the inner term.
The current post’s terms. On a single post template, the Current post term option returns only the terms assigned to the post being viewed, which is how you build the small category chips above an article title. The documentation says to use it only in a single post context. For more complex rules, the terms query filter lets you change the arguments, for example to fetch the terms of a specific post by passing its ID in the object IDs argument. Use the filter signature from the documentation, with the element ID check, so only one loop changes.
One practical tip. Categories that you do not want to list, such as the default Uncategorized, are best excluded with the Terms Include and Exclude control rather than hidden with CSS, because CSS leaves the term in the HTML and in the count of items. And if the taxonomy has hundreds of terms, a terms loop with no limit is a performance cost, so cap the Number. The figure shows the result as plain HTML and CSS.

Pagination basics and the archive main query
A loop that shows every result on one page does not scale. Pagination splits the results into pages, and in Bricks it is a separate element, which gives you freedom over where and how it looks.
Add the Pagination element, found in the WordPress group of the Elements panel, and link it to a loop using its query setting, which the documentation describes as selecting which query the pagination controls. This link is by loop, which is why naming loop elements descriptively pays off when a page has several. The element has styling controls for the buttons, the current page, previous and next icons, and the spacing, and two miscellaneous values: End Size, the number of page numbers shown at the start and end, and Mid Size, the number shown on each side of the current page.
Three rules make pagination reliable.
The page size comes from the loop. For posts it is Posts Per Page, and for terms and users it is Number. The total number of pages is computed from the result count, which is why switching on No Found Rows breaks pagination: that option skips the count query. Use No Found Rows only on loops that never paginate.
Stable ordering prevents duplicates. If you sort by something that can repeat, such as a price or a rating, results can shift between pages, so the same item appears twice or never. The Bricks documentation advises adding ID as a secondary ordering criterion when you paginate. Random ordering has a similar issue, and Bricks provides a random seed lifetime in minutes so the same random order holds across pages for a while.
On archives, mark one main query. On an archive or search results template, WordPress already has its own query for the page, and Bricks merges loops with it by default. Turn on Is main query (Archive, Search) on the loop that forms the main listing, and make sure the Pagination element targets that same loop. If you do not, page two of the archive can return a 404. Only one loop per template should be marked, since only the first is honoured, and secondary loops, such as a featured strip in the sidebar, should have Disable Query Merge on so the archive query does not bend them.
Beyond numbered pages, Bricks supports AJAX pagination, a Load More behaviour added to a button through an interaction, and infinite scroll. They all rely on the loop comment markers mentioned earlier, and on the loop’s ID to find their target. Each has its own settings, which a separate guide covers, so this section sticks to the basics. A last caution about Offset: skipping items is useful for a “featured item plus list” layout, but offset and paging interact in WordPress, so test page two and three before you ship a loop that combines them.

Designing the empty state
A loop with no results is not an error, it is a normal state. A new site has no posts in a category yet. A related posts query for a post with no category finds nothing. An author with a rare role returns an empty list. If you do not design for it, visitors see an unexplained heading with a blank space, or no section at all and a layout that looks unfinished.
Bricks gives you several tools. Every query loop can show fallback content when no results match. For terms and users loops there is a No Results text control for a short message. The documentation also mentions a no-results template where that option is available, so you can build a richer fallback, such as a short explanation with a link to the latest posts. Check the Query control in your version for which of these appear. Bricks may still process the loop’s child elements internally when there are no results so that scripts, styles and popup assets are prepared, but that does not mean placeholder content is shown to visitors.
For full control in PHP there is a filter for the no results content. It receives the current content, the element settings and the element ID, and returns the content to show:
add_filter( 'bricks/query/no_results_content', function ( $content, $settings, $element_id ) {
// Replace abc123 with the six-character ID of your related posts loop.
if ( 'abc123' !== $element_id ) {
return $content;
}
return '<p class="loop-empty">' . esc_html__( 'No related articles yet. Browse the latest posts instead.', 'your-textdomain' ) . '</p>';
}, 10, 3 );
The callback exits early for every other loop, so it only changes the one you target. For the matching loop it returns a paragraph whose text goes through esc_html__, which translates the string and escapes it. Replace the text domain with your theme or plugin’s. The Bricks documentation’s own example returns a Bricks section template through a shortcode, which is the route to take if the empty state needs real design.
The paragraph carries a class so you can style it. This CSS, added to the page or template custom CSS or to a global class, turns the bare message into a panel that looks intended:
.loop-empty {
margin: 0;
padding: 1.25rem 1.5rem;
font-weight: 600;
color: #12285f;
background: #f5f8ff;
border: 1px solid #c7d2e6;
border-radius: 12px;
}
The padding and border give the message the same visual weight as a card, so the empty section does not collapse into a stray line of text, and the colours keep enough contrast for reading. The figure at the end of this section compares a heading over blank space with the panel. The filter returns HTML, so you can add a next step to the string, such as an anchor whose address goes through esc_url and whose text goes through esc_html__. Once the message needs more than a sentence and a link, a section template, as the documentation suggests, is easier to maintain than HTML inside PHP.
Good empty states do three things. They say plainly what is missing, they offer a next step such as a link to a wider list, a search form or the latest items, and they do not look like a bug. For a related posts section there is a fourth option, which is to show nothing at all, including the heading. Because a heading placed outside the loop would show above nothing, wrap the heading and the loop together in one element and put an element condition on that wrapper. The results count tag, which accepts the loop ID when used outside the loop, is the natural input. Test it on a post with no results, and check the Element conditions documentation for the operators your version offers.
Also think about why a result could be empty beyond missing content: a meta query comparing the wrong format, an include list of IDs that points at the wrong post type, a role filter that matches nobody. When you see an empty state on content you know exists, the query is the first suspect, not the content.

What goes wrong: symptoms and causes
Most loop problems fall into a few patterns. Match the symptom, then check the cause.
- The whole grid repeats, not the cards. Use Query Loop is switched on at the wrapper. Move it to the element that should appear once per result.
- Every card shows the page title or the same data. The dynamic tag is outside the looping element, or the loop is switched on at the wrong level. Place the tag inside the loop and check it fits the query type.
- A term or user tag shows nothing. The tag belongs to a different query type. In a posts loop use post tags, in a terms loop use term tags and in a users loop use user tags.
- Media loop images are missing. The card uses the featured image tag. For attachments, use the post ID tag as the image source.
- Related posts show the latest posts instead. The PHP filter’s element ID does not match, the single-post condition fails, or you are judging the canvas. Check on the frontend and re-copy the loop’s ID.
- The wrong posts appear on an archive. The loop merges with the main query, or a second loop is marked as main. Mark one main query and disable merging on the others.
- Page two returns a 404. The Pagination element targets a different loop than the main query, or more than one loop is marked main.
- The same item appears on two pages. The ordering is not unique. Add ID as a secondary sort.
- Load more, AJAX pagination or filters stop working. An optimisation plugin removed the loop HTML comments, or the target query ID changed after you duplicated or rebuilt the loop element.
- The Query editor does nothing. Code execution is off, your user lacks the capability, or the code is unsigned or its signature is invalid. Unsigned code is highlighted in the builder. Regenerate signatures after salts or keys change.
- A meta query returns nothing. It compares the stored value, not the displayed one, or the type is wrong. A date field stored as a compact number needs a numeric comparison with a value in the same format.
- A loop inside a loop is slow or confusing. The inner loop runs once per outer item and cannot read the outer result with tags. Keep nested loops small and read parent values outside the inner loop.
- The builder shows a different count from the frontend. The canvas can limit results for speed, and the builder renders in its own request, so page-specific rules may not apply there.
The fastest debugging habit is to simplify. Remove the filter, the meta query and the extra toggles until the loop works with the bare query, then add the pieces back one at a time. The piece after which it breaks is the cause.
Checklist
- Design one card first, then switch on Use Query Loop on the card element, not on its grid wrapper.
- Name each looping element descriptively and note its six-character ID if you will target it with PHP.
- Choose the query type by what you list: posts, terms, users, or API and array for outside data.
- Set Posts Per Page or Number deliberately, and avoid unlimited results on large sets.
- Use Exclude Current Post for related content, and add a category or tag rule through the interface or a documented filter.
- Turn on Disable Query Merge for any loop that is not the main listing, especially in headers and footers.
- Use dynamic tags that match the query type, and place them inside the looping element.
- For media loops, use the post ID tag for the image and avoid the featured image tag.
- Show only intended user data in a users loop, never email addresses or login names.
- Limit author lists to users with published posts, and plan for missing photos and bios.
- Keep PHP filters in a child theme or site plugin, and target one loop by its element ID.
- Enable code execution and the Query editor only for trusted users, and keep editor code limited to returning query arguments.
- Mark exactly one loop as the main query on an archive and link the Pagination element to it.
- Add ID as a secondary sort when paginating by a value that can repeat.
- Use No Found Rows only on loops that never paginate.
- Design an empty state for every loop, with a clear message and a next step.
- Test loops on the frontend, logged out, including the case with zero results, not only in the builder canvas.
- Keep nested loops small and avoid reading parent results from inner markup.
Read this next
About this guide. This is general guidance written by WPresident Editorial from documentation and widely used practice. WPresident has not benchmarked the products or methods described. Interfaces and plan limits change, so check the vendor’s current documentation before you act. Not legal, tax or financial advice. See our editorial policy.
Frequently asked questions
What is a query loop in Bricks Builder?
A query loop turns a layout element into a repeater. You design one item, choose where the data comes from, and Bricks renders that item once for every result. The data can come from a posts, terms or users query, from an external API, or from an array. Inside the loop, dynamic data tags read the current result instead of the page. It is how you build latest posts, related posts, category lists, team grids and directories without copying elements by hand.
Which Bricks elements can use a query loop?
Layout elements such as Container, Section, Block and Div can loop through the Use Query Loop setting, and so can the classic Accordion and Slider elements. The Map element has its own loop controls for dynamic addresses, and the nestable Accordion, Tabs and Slider elements use their own child repeaters instead of the full loop control. Check the element's page in the Bricks documentation for how a particular element takes dynamic items in your version.
Why does my whole grid repeat instead of the cards?
The loop is switched on at the wrapper, so the wrapper is the repeated element. The element with Use Query Loop enabled is the one that repeats. Put the loop on the card, the Block or Div that should appear once per result, and leave the surrounding grid wrapper without a loop. The wrapper then renders once and holds one card per result. Renaming the looping element in the structure panel helps you spot this mistake.
Why do my dynamic data tags show the page title on every card?
Tags only read the loop result when they sit inside the looping element. A tag placed outside it, or a loop enabled at the wrong level, reads the page instead. Also check that the tag matches the query type: post tags for posts, term tags for terms, user tags for users. When testing, drop the tag into a plain text element inside the loop and look at what it returns before wiring it into an image or link.
How do I build a related posts section in Bricks?
The quickest route is the Related Posts element, which finds posts that share taxonomies with the current one and has controls for the number, order and layout. For more control, build a posts query loop in a single post template with Exclude Current Post and a small per-page limit, then restrict it to the current post's categories through the interface if your version allows it, or with the documented posts query filter. Always judge the result on the frontend.
Is the Query editor (PHP) safe to use?
It runs PHP stored in the database, so Bricks gates it. Code execution must be enabled in the settings, the user needs the execute code capability, and the code must carry a valid signature or it will not run. Enable it only for trusted users, keep the code to returning query arguments, and never echo output or write data inside it. For long-lived or important logic, a filter in a child theme under version control is usually the better home.
How do I list authors with a users query?
Add a card element with Use Query Loop, set the type to users, and choose the role your authors have. Show the display name, picture and bio with the user tags, and link to the author's page. Avoid emails and login names. WordPress can limit a user query to users with published posts, which the Bricks users filter lets you add, so you do not link to empty author archives. Test with a user who has no picture or bio.
Why does page two of my archive give a 404?
Usually the archive's main query and the pagination do not match. On archive and search templates, turn on Is main query on exactly one loop, and make sure the Pagination element targets that same loop. Marking more than one loop as the main query does not work because only the first is used. Loops that are not the main listing should have Disable Query Merge switched on so the archive query does not alter them.
What should I show when a query loop has no results?
Show a deliberate empty state. Terms and users loops have a No Results text, queries can use a fallback template where that option is available, and a PHP filter can return your own content for a specific loop. Say what is missing and offer a next step, such as a link to the latest items. For a section like related posts you may prefer to hide the heading and loop together with an element condition on a wrapper, and test that case.
Can I loop through a loop in Bricks?
Yes, loops can be nested, but each inner loop runs once per outer item, so the cost and the DOM grow quickly. Dynamic tags inside an inner loop read the inner result, and Bricks provides no syntax to read the parent result from inner markup, so keep parent values outside the inner loop or use custom PHP. Keep nested loops small, and see a dedicated guide on nested query loops for patterns that work.
How many results should a Bricks query loop show?
Set a number deliberately for every loop. For posts the default comes from the WordPress Reading setting for blog pages, and terms and users use a Number control that also defaults to that value. Avoid unlimited values on large datasets, because they increase database work and page size. Pick a count that fits the design, such as three for related posts, and add pagination, Load More or infinite scroll when users need to see more.



