Created
November 29, 2025 20:20
-
-
Save morgyface/54dfe6b1af9a96c2007882cf9f053790 to your computer and use it in GitHub Desktop.
WordPress | ACF | Repeater, display all sub-fields without specifically getting them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 triedprint_r(the_row())it only displayed two rows and then stopped. Apparently my mistake here was usingthe_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.