Home › Forums › Backend Issues (wp-admin) › Loop through posts if True/False › Reply To: Loop through posts if True/False
Hi,
If you want to show only the posts that have a true/false checkbox checked (the checkbox that trigger the two other field on your backend).
you should restrict to these posts directly on your query
'meta_query' => array(
'post_type' => 'areas-of-focus',
array(
'key' => 'is_a_featured_area_of_focus',
'value' => '1',
'compare' => '=='
)
)
something like that should return only the posts that have the is_a_featured_area_of_focus
field set to true.
so you can get rid of if( get_field('is_a_featured_area_of_focus') ) :
and other stuff related to checking if this field is checked on the loop and just take care of the layout.
let me know how that goes
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.