ACF Loop Quantity

Hey guys, you can easily use the acf/format_value hook to limit the number of items to output.

/*
 * change "my_repeater" in the hook name
 * to the name of the ACF repeater you want to limit
 */
add_filter( 'acf/format_value/name=my_repeater', function( $value, $post_id, $field ) {
    $max_items = 3; // max number of items you want to output
    return ( count( $value ) > $max_items ) ? array_slice( $value, 0, $max_items ) : $value;
}, 10, 3 );

Backend:

Frontend:

CleanShot 2023-01-29 at 14.44.03

7 Likes