Created
July 30, 2025 00:40
-
-
Save wplit/1856191789df54ab049db7e60aeaf1c9 to your computer and use it in GitHub Desktop.
custom function for gallery image count
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 | |
| function acf_gallery_count($field_name, $post_id = null) { | |
| $gallery = get_field($field_name, $post_id); | |
| $count = is_array($gallery) ? count($gallery) : 0; | |
| return $count; | |
| } |
Author
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

remember to add the function name to the list of allowed custom functions - https://academy.bricksbuilder.io/article/filter-bricks-code-echo_function_names/
add_filter( 'bricks/code/echo_function_names', function() { return [ 'acf_gallery_count', ]; } );