Home › Forums › General Issues › ACF Galleries displaying empty › Reply To: ACF Galleries displaying empty
This will always be true
if ($logos = get_field("as_seen_on_logos", "options")):
true or false in this case is dependent of if a value is assigned to $logos and that will always happen even if the field has no value.
You need to get the value and then test the value, as far as I know you cannot do this all in the if, to test you can also display the value to make sure you’re getting what you expect.
$logos = get_field('as_seen_on_logos', 'options');
echo '<pre>'; var_dump($logos); echo '</pre>'; // test
if (!empty($logos)) {
// loop over logos
}
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.