Home › Forums › Front-end Issues › Sub dividing posts in archive based on true/false › Reply To: Sub dividing posts in archive based on true/false
OK, a couple of observations:
Why are the queries run inside a default while ( have_posts() ) : the_post();
loop? Remove that loop or move the additional queries outside of it and go from there.
To debug this I would do a standard query first and var_dump
or print_r
the return value of the custom field in question to see what values are actually returned. Is it actually a string, as you seem to be testing for? Or is it true/false or 1 or 0 as integers?
You should use wp_reset_postdata(), not wp_reset_query(), as this is only for use with query_posts(), as far as I understand, which isn’t recommended anyway (source: https://developer.wordpress.org/reference/functions/wp_reset_query/).
You can probably use a basic query, as described on https://www.advancedcustomfields.com/resources/query-posts-custom-fields/, since you are just querying for one field anyway.
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.