23rd Jun '23/14 commentsBricks Query Loop – How to Insert Elements After Every Nth PostSridhar Katakam Update: Follow this tutorial instead. This Pro tutorial provides the steps to output element(s) in a Bricks' query loop after every nth post. Use case: Show an ad after every 3rd post. This is based on the previous How to Insert Element(s) Between Query Loop Posts in Bricks tutorial. It is possible to apply display: grid to the query loop element's parent if a grid layout is needed. Note This might break pagination. Implement this only for a non-paginated list of posts. Step 1 Let's define a couple of custom functions for getting the loop index and the modulus of loop index. Add the following in child theme's functions.php or a code snippets plugin: This is a BricksLabs Pro tutorial. For full access login below or create your BricksLabs Pro account Username Password Remember Me Forgot Password Tagged: BricksLoop IndexProSridhar KatakamSridhar Katakam is a Bricks enthusiast. He likes helping others by researching and solving WordPress-related problems and building websites.Get access to all 634 Bricks code tutorials with BricksLabs Pro
How to apply a custom query var to multiple query loops in BricksIn this tutorial, we'll learn how to apply a PHP filter to modify the query var of multiple query loops in a single function Introduction…Read more →Categories: Bricks, FreeTags: Dynamic Data, Query Loop
Pro Nested Query Loops with Dynamic Author Filtering in BricksThis Pro tutorial provides the steps to set up nested query loops in Bricks for grouping posts by their authors. For the posts under each…Read more →Categories: Bricks, Plugins, ProTags: BricksExtras, Nested Queries, Pro Accordion
Pro Post sub field Bricks Query Loop in a Meta Box Group fieldLet's consider this Meta Box field group for Pages: FAQs is a Group-type of field in which one of the sub fields is "Answer Post",…Read more →Categories: Bricks, Plugins, ProTags: get_query_for_element_id, Meta Box, Nested Queries
Pro Accordion Grid Query Loop in BricksHow to set up a accordion in Bricks such that the "titles" are arranged in a grid with the full width content opening below.Read more →Categories: Bricks, ProTags: Accordion, CSS, Query Loop
Pro Meta Box Cloneable Field Query Loop in BricksUpdated on 5 Mar 2025 This Pro tutorial provides the steps to create a custom query type for outputting the values of one or more…Read more →Categories: Bricks, Plugins, ProTags: Custom Query Type, Meta Box, Query Loop
Pro Related Posts Grouped by Custom Field Value when using ACF Relationships in BricksIn the Bricks Facebook group a user asks: Let's summarize the situation. with the CPTs and field groups created using ACF. Requirement: On single locations,…Read more →Categories: Bricks, Plugins, ProTags: bricks/element/settings, Custom Query Type, Query Loop
Pro Hierarchical Posts with Nested Query Loops in BricksLearn how to set up nested query loops in Bricks to show hierarchical posts with child posts grouped under their corresponding parent postsRead more →Categories: Bricks, ProTags: Nested Queries
Pro Recently Viewed Posts Bricks Query LoopHow to output the most recent X number of posts (any post type) viewed by the current visitor.Read more →Categories: Bricks, ProTags: Cookies, Query Loop
Adding any Custom WP_Query loop to Bricks’ Query LoopSometimes we may need to create a custom post loop using Bricks' query loop feature, but wish to use our own WP_Query code for more…Read more →Categories: Bricks, FreeTags: bricks/query/run, Query Loop, WP_Query