Support

Account

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 ‘' . esc_attr($image['alt']) . '‘;
    endforeach; endif;
    endwhile; wp_reset_postdata(); endif;
    ?>
    I used a similar approach on Photoapkleap site to handle image content. Hope this helps!