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
That could be because I have the wrong value in the arguments “signature_event” instead of “1”. Basically what I was trying to highlight is that you had your query arguments nested improperly.
$args = array(
'post_type' => 'events',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'signature_event',
'value' => '1',
'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.