Query Loop Index in Bricks

This Pro tutorial provides the code for getting the index of each post in Bricks' query loops.

This can be used for either outputting the post number (screenshot below) or for checking for nth post and conditionally outputting elements (Ex.: How to Insert Element(s) Between Query Loop Posts in Bricks).

Note: If you have BricksExtras installed, there is no need to use the below custom function. BricksExtras comes with it. Check the Dynamic Tags doc page.

Step 1

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

Instant access to 390+ Bricks code tutorials with BricksLabs Pro