Created
November 5, 2018 20:45
-
-
Save interactiveRob/b7f2d0d768ba907c486b267d93ef010b to your computer and use it in GitHub Desktop.
Check if ACF group has content
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
| function acf_group_has_content($group){ | |
| /* Necessarily checks if a groups sub_fields have content | |
| because the ACF group always returns true even when the | |
| group is empty */ | |
| foreach ($group as $item): | |
| if($item): | |
| return true; | |
| endif; | |
| endforeach; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage
$my_acf_group = get_field('my_acf_group');if( acf_group_has_content($my_acf_group) )://do somethingendif;