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 6 Random Posts from Tag A + 6 Random Posts from Tag B in a Single Bricks Query LoopDisplaying two set of random posts, inside one query loop.Read more →Categories: Bricks, ProTags: Query Loop
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 Query Loop Index in BricksThis Pro tutorial provides the code for getting the index of each post in Bricks' query loops. This can be used for either outputting the…Read more →Categories: Bricks, ProTags: Loop Index
Pro Staggered Entry Animations for Posts in Bricks Query LoopsThe steps for animating the posts output by a Bricks query loop in a staggered animation.Read more →Categories: Bricks, JavaScript, Plugins, ProTags: Animations, Query Loop
Pro Non-empty events sorted by event date and other posts below in BricksUpdated on 15 Jan 2024 Consider a scenario where you are showing posts from multiple post types namely post, event and game in a single…Read more →Categories: Bricks, ProTags: meta_query
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 Limit the Number of Posts in a Bricks Query Loop of Relationship TypeUpdated on 12 Dec 2023 Bricks Query Loop popup does not have a control for setting the number of posts to be output when the…Read more →Categories: Bricks, ProTags: bricks/query/run, Filters, Query Loop
Pro Search Results Grouped by Post Types in BricksUpdated on 08 Oct 2024 This Pro tutorial provides the steps to arrange the search results by specified post types in a Bricks site. We…Read more →Categories: Bricks, ProTags: Nested Queries, Search Results
Pro Displaying Gallery of SureCart Product Images with Bricks’ Query LoopCustom query loop for looping through SureCart product images.Read more →Categories: Bricks, Plugins, ProTags: SureCart