Support

Account

Home Forums ACF PRO List all entries from a custom field Reply To: List all entries from a custom field

  • you can achieve this with simple WP’s query.

    One thing to keep in mind, acf’s value are saved in the “wp_postmeta” table. So, your code would be similar to these lines:

    
    $args = array (
        'post_type' => 'post', // your post type
        'posts_per_page' => -1, // grab all the posts
        'meta_key' => 'your_acf_image_field_name', 
        'meta_compare' => 'EXISTS' // make sure the post have this acf value
    );
    
    $query = new WP_Query($args);
    
    while ($query->have_posts()): $query->the_post();
        // because the image value is saved as attachment_id
        echo wp_get_attachment_image( get_field('your_acf_image_field_name') );
    endwhile;
    
    wp_reset_query();