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 endforeach; ?>
<?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 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!
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.