Get 30% discount on lifetime membership by using BFCM2023 coupon.
Offer ends on 30th Nov 2023 at 11:59:59 PM UTC.

Loop Item ID and Loop Item Object in Bricks

If you are working on a Bricks site with specific requirements, chances are you need to grab the ID and/or object of the current item (post/term/user) in the loop when using a Query Loop.

We used the following in several tutorials already on the site but just posting these here as a separate topic for easy reference.

Loop Item ID


To show it as a dynamic data tag in a text element, register a function:

function bl_get_loop_item_id() {
	return \Bricks\Query::get_loop_object_id();



Loop Item Object


To see all the properties of the object:

print( '<pre>' . print_r( \Bricks\Query::get_loop_object(), true ) . '</pre>' );


Instant access to all 250+ Bricks code tutorials with BricksLabs Pro

Leave the first comment