Grouping ACF Post Objects by a Repeater Sub Field in Bricks

Consider the following scenario.

CPT: product (from WooCommerce)

ACF field group for the product post type: A Repeater with a Select sub field and Post Object sub field that's limited to product CPT.

Repeater field being populated on a sample product edit screen:

So every product will have its own related products (books) in different languages.

The objective is to group these related books by their language (the sub field value) and show them in a slider.

In this Pro tutorial, we shall write a custom function that loops through all the Repeater rows and forms an associative array of languages mapped to the array of corresponding products, register a custom query type of 'Product Languages' taken from the function and use this in a Bricks nestable slider.

Step 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

Instant access to 390+ Bricks code tutorials with BricksLabs Pro