As I said, the gallery field is one of the more complicated fields.
Yes, you would replace THE_NAME_OF_YOUR_GALLERY_FIELD
with the name of your gallery field and then where it says // do something special for gallery fields
you would add code that output the gallery the way you want.
Did you look at the link I gave you? There are several examples of code for showing a gallery in different ways. https://www.advancedcustomfields.com/resources/gallery/