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 633 Bricks code tutorials with BricksLabs Pro
Pro Custom SQL Ordering for Sorting Events in BricksShowing events ordered by the event date with upcoming events in ascending order and past events in descending order.Read more →Categories: Bricks, ProTags: Ordering, Sorting, SQL
Pro Top-level Pages and Children Bricks Query LoopThis Pro tutorial for Bricks users can be considered Part 2 or a variation of the earlier Bricks Query Loop for Top-level Parent Pages with…Read more →Categories: Bricks, ProTags: Nested Queries
How to display a Query Loop in 3 columns in BricksThis tutorial provides the builder settings and CSS codes that can be pasted in order to create a 3-columns query loop container inside Bricks Builder.Read more →Categories: Bricks, FreeTags: CSS, CSS Grid, Flexbox, 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 YouTube Playlist Bricks Query LoopA custom query type, for displaying YouTube playlist in a Bricks query loop.Read more →Categories: Bricks, ProTags: API, Custom Query Type, Query Loop, YouTube
Pro Filtering posts by a group field’s subfield value with Meta Box when using a custom table in BricksFiltering a query loop to output only those posts with the value of a Select subfield of a Group field set to Yes when using…Read more →Categories: Bricks, Plugins, ProTags: Meta Box
Pro YouTube Video Timestamps in BricksThis Pro tutorial provides the steps to output a YouTube video given its ID with custom timestamps and their description text using ACF Pro or…Read more →Categories: Bricks, Plugins, ProTags: ACF Pro, ACF Repeater, Interactions, Loop Index, Meta Box
Pro ACF Post Object Query Loop inside a Posts Query Loop in BricksHow to loop through a CPT and within each post, output a list of related posts.Read more →Categories: Bricks, Plugins, ProTags: ACF, Nested Queries
Pro Nested Queries in Bricks – Posts Grouped by Published Years and CategoriesIn the past we showed how posts could be grouped by years in Bricks. This Pro tutorial takes it further by grouping posts by categories…Read more →Categories: Bricks, ProTags: Query Loop