Home Forums ACF PRO Form + ACF Gallery Field = Upload photos with descriptions to gallery


Form + ACF Gallery Field = Upload photos with descriptions to gallery

  • Hi! I’m very new to the ACF world and coding isn’t my strongest!

    I have successfully added a GalleryField through a WPForm so my site members don’t need to see the WP dashboard at all. They can use the form to upload a post together with an image gallery, where the first picture will obviously be the featured image.

    I’ve also created form fields so the author can write the attached photos TITLES.

    Now I’m trying to create a function that will basically pull those ACF fields (they have correctly uploaded to the post custom meta fields) into the actual gallery images titles.

    I started coding but realized I’m not 100% sure how to access the images within the GalleryField! Can anyone help? Thanks in advance!

  • If I’m understanding you right, it sounds like you need the code from the Gallery field’s main page? I’ll paste it here.
    $images = get_field(‘gallery’);
    if( $images ): ?>

    <?php endif; ?>’

    Does that help?

  • Hi! thanks for your reply.

    I’m a bit confused… So I already got the titles for the attached photos in the Post settings thanks to ACF.

    I only need to assign those ACFs to the actual gallery/photos’s file names / alt text, or whatever field so that then they show up when viewing the gallery.

    I fail to understand how to assign those titles to the photos, can you help ne please?

  • I will try to – can you share the code you are using to get the titles? By titles do you mean the title attribute of images? If so and that’s working, then if I’m not mistaken (which often I am) you should be able to get url, alt, caption in the same way.

  • I have no code yet! Not sure where it would go? everything goes to the functions.php in the theme-child folder?

    The titles (yes, I mean the title attribute) are entered in a “send your post” page I created (image attached). The WPForm is perfectly creating the posts with the Post Title, excerpt, body text, Category option, featured image and its sending any other attached image to the post field-gallery so that’s perfect!

    What I need now is that those extra fields for the images’ captions or titles are automatically assigned to the uploaded pics. Makes sense?

    I’ve already created ACF for the field-gallery and each of the images’ titles.

    So I think I only need code that says:
    “When a post is created, use these texts in the corresponding uploaded photos in the gallery as their titles.”

    Sorry my engish is not perfect, as you’ll see in the attachment, I’m a spanish speaker!

    Thank you Ben for whatever you can help me with!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.