Home › Forums › Front-end Issues › Show All Posts with True on True/False Field › Reply To: Show All Posts with True on True/False Field
The query should look like this, I’ve separated the arguments from the function so that they are easier to see.
$args = array(
'post_type' => 'events',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'signature_event',
'value' => 'signature_event',
'compare' => '==' // not really needed, this is the default
)
)
);
$the_query = new WP_Query($args);
if ($the_query->have_posts()) {
// This
// if( get_field('signature_event') )
// isn't needed since we did a query to only get ones
// with a true value
?>
<ul>
<?php
while ($the_query->have_posts()) {
$the_query->the_post();
?>
<li><a href="<?php page_link(); ?>"><?php the_title(); ?></a></li>
<?php
} // end while have posts
?>
</ul>
<?php
wp_reset_postdata();
} // end if have posts
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.