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
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!
© 2022 Advanced Custom Fields.