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 626 Bricks code tutorials with BricksLabs Pro
Pro Mixed Post Types Grid in BricksHow to set up a mixed post types grid in Bricks, where you can display both standard posts and custom quote cards in alternating positions.Read more →Categories: Bricks, ProTags: Query Loop
Pro Dynamic Horizontal Posts Accordion in BricksUpdate on 8 Sep 2024: You may want to follow the newer version that considers accessibility. Looking to make a Horizontal Image Accordion dynamic? This…Read more →Categories: Bricks, ProTags: Horizontal Accordion, Query Loop
Pro Post ID Query Variable-based Post Output in BricksHow to query a single post of a custom post type using the post ID passed to a page via a URL parameter.Read more →Categories: Bricks, ProTags: Query Variables, URL Parameter
How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 4)This tutorial provides the PHP & JS codes that can be pasted in order to filter your markers on a map based on terms of…Read more →Categories: Bricks, Free, PluginsTags: ACF, Animations, Filters, Isotope, Leaflet, Query Loop
Pro Ordering Posts by Terms in BricksHow to output upcoming events at the top and past events below in a single query loop in Bricks.Read more →Categories: Bricks, ProTags: Query Loop
Pro Masonry for Query Loop in BricksIf you are looking to implement masonry with a 'view more' button i.e., click-type of infinite scroll follow this tutorial instead. Updated on 15 Mar…Read more →Categories: Bricks, ProTags: Masonry, 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 Posts Grouped by Post Dates in BricksSetting up query loops for “Post Dates” with an the inner loop displaying all posts published on that day.Read more →Categories: Bricks, ProTags: Nested Queries
Pro Outputting an Element in Bricks x times where x is a custom field valueLearn how to output a query loop item(s) as many times as the value of a custom field in Bricks.Read more →Categories: Bricks, ProTags: Array, Query Loop