Support

Account

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.