Display gallery on posts with ACF

Hello,
I’m trying to use ACF to display a gallery under the text of each post.
I have added the line <?php the_field('project_gallery'); ?> to single.php and created a custom field by the same name. I have set the Return Format to “Image URL”, however on the front end it is simply displaying the image urls separated by commas. How can I get the images themselves to display in a gallery?

Hey @mkob,

Thanks for reaching out!

If you want to display ACF Gallery, you may check this article.

Hope that helps.

Hi, thank you for your help. I’ve been successful in adding the gallery. However, what I need to do is add it to content.php, rather than wp-single.php. Could you please point me in the right direction?

For clarity, what I’m trying to do is add a custom field for an image gallery, then display that image gallery as part of the post content, not below or above the content.

Hello @mkob,

You do not need to edit the content.php or any of the theme files. You can go to Cornerstone > Layout Builder and create a custom single layout. You can then use a Looper Provider to display the ACF gallery. Perhaps this video demonstration can help you:

If you are not familiar with the layout builder, please check this out first:

And then check out this video too:

Best Regards.

Thank you for the resources. These methods, however, will still not display the gallery as part of the content. They will display it as separate elements. Is there a way I can edit php files to display a gallery directly underneath the post content text as part of the post content?

Hey @mkob,

The resources given by my colleague above are the right way to address your issue but if you prefer custom coding, I suggest that you extend the content.php on this file path framework > views > your stack > content.php in your child theme. This will allow you to add the gallery inside the post content. Please note that custom coding is outside the scope of our support. You may seek 3rd party developers to help you with your problems or you can avail One where we can answer questions outside of the features of our theme.

Hope that helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.