Skip to content

Instantly share code, notes, and snippets.

@morgyface
Created November 29, 2025 20:20
Show Gist options
  • Select an option

  • Save morgyface/54dfe6b1af9a96c2007882cf9f053790 to your computer and use it in GitHub Desktop.

Select an option

Save morgyface/54dfe6b1af9a96c2007882cf9f053790 to your computer and use it in GitHub Desktop.
WordPress | ACF | Repeater, display all sub-fields without specifically getting them
<?php
if( have_rows('awards') ):
while( have_rows('awards') ) : $row = the_row();
$row = array_filter($row, 'strlen'); // filters out all the empty values
echo implode(' - ', $row); // Displays all the values as a hyphen seperated list
endwhile;
endif;
@morgyface
Copy link
Author

morgyface commented Nov 29, 2025

Show all ACF repeater sub-fields

I recently came up against a situation where my ACF repeater rows had six fields/keys each. This would've meant unnecessary and verbose code as I wanted to display all the values regardless.

My first challenge was to try and get all the contents from the_row(), however when I tried print_r(the_row()) it only displayed two rows and then stopped. Apparently my mistake here was using the_row() twice. To solve this I turned it into a variable using $row = the_row() ( thanks @elliotcondon ).

Now all I had to was implode and it worked... however it was including empty values, so I removed them using array_filter($row, 'strlen').

Job done. Useful to keep a record of this for future reference and in case anyone else comes up against it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment