4th May '26
/
0 comments

Nested Query Loops with Dynamic Author Filtering in Bricks

This Pro tutorial provides the steps to set up nested query loops in Bricks for grouping posts by their authors.

For the posts under each author, we shall show one latest post with the rest appearing after an accordion's button is clicked.

Step 1

Install and activate BricksExtras.

Enable Pro Accordion element.

Step 2

Let's define three custom functions:

  • bl_get_loop_user(): returns the WP_User object from the specified loop (in this case, the outer user query loop)
  • bl_get_loop_user_prop(): returns the specified property (like ID) from the WP_User object currently being looped through in the outer user query loop
  • bl_get_loop_user_post_count(): returns the number of published posts authored by the user in a Bricks query loop minus 1

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 633 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Post-specific ACF Repeater Galleries as Sliders in Bricks

Post-specific ACF Repeater Galleries as Sliders in Bricks

How to output ACF Repeater field rows with the images of the Gallery-type sub field as a slider.
Pro
Post ID Query Variable-based Post Output in Bricks

Post ID Query Variable-based Post Output in Bricks

How to query a single post of a custom post type using the post ID passed to a page via a URL parameter.
How to add a layout toggle on query loops in Bricks

How to add a layout toggle on query loops in Bricks

In this tutorial, we’ll show you how to change the layout of your query loop container based on the click of an icon toggle sitting…
Categories:
Pro
How to Move an Element into Another on Smaller Viewports in Bricks

How to Move an Element into Another on Smaller Viewports in Bricks

This Pro tutorial provides the steps to move a Block containing a Heading and WP Grid Builder's Facet into BricksExtras' OffCanvas element for viewports 991px…
How to apply a custom query var to multiple query loops in Bricks

How to apply a custom query var to multiple query loops in Bricks

In this tutorial, we'll learn how to apply a PHP filter to modify the query var of multiple query loops in a single function Introduction…
Categories: