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();
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.