How To Limit Output ACF Repeater in Query Loop

I’ve searched the forums, but I can’t find a solution. I have an ACF repeater with an image element in it. That works flawlessly using a query loop, but I only want to display 2 images. Otherwise, the browser will download 10+ images, for example.

I know I can hide it with CSS, but the images will still get downloaded.

Is there a solution? I also tried using the Query Editor (PHP) but that didn’t return anything.

image

Solution that worked flawlessly

1 Like

I’d love to know how to do this too.

This bricks Filter should work:

add_filter('bricks/query/result', function ($result, $query_obj) {
  // Return all Elements except with the Bricks ID of "tudihi"
  if ($query_obj->element_id !== 'tudihi') return $result;

  $result = array_slice($result, 0, 2);

  return $result;
}, 10, 2);

Change the ID for your Bricks ID (of the query-loop element (div / block).

Maybe it’s a bug, but it should also work with Filter: bricks/query/result_count, but i couldnt make it work :sweat_smile:

Hope this Helps

1 Like

Thank you! I ended up doing exactly this a few days ago.

1 Like

My problem now is that neither pagination, nor the “Load More” button knows that there is more query items.