Home › Forums › ACF PRO › Show all image galleries in home page › Reply To: Show all image galleries in home page
You can achieve this using WP_Query to fetch all “Galleries” posts and retrieve images from the ACF gallery field. Try this:
php
Copy
Edit
<?php
$query = new WP_Query([‘post_type’ => ‘galleries’, ‘posts_per_page’ => -1]);
if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
$images = get_field(‘gallery’);
if ($images) : foreach ($images as $image) :
echo ‘‘;
endforeach; endif;
endwhile; wp_reset_postdata(); endif;
?>
I used a similar approach on Photoapkleap site to handle image content. Hope this helps!
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.