Home › Forums › General Issues › Loop ALL fields within sidebar › Reply To: Loop ALL fields within sidebar
You need to do a query to get the posts http://codex.wordpress.org/Class_Reference/WP_Query and loop through the results
$args = array(
'post_type' => 'post', // or your post type
'posts_per_page' => -1, // get them all
'meta_query' => array(
array(
'key' => 'logo',
'value' => '',
'compare' => '!='
)
)
);
$query = new WP_Query($args);
if ($query->have_posts()) {
global $post;
while ($query->have_posts()) {
$query->the_post();
// code to display fields from each post
// same as done on a single post
}
wp_reset_postdata();
}
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.