Home › Forums › Add-ons › Flexible Content Field › Show Empty Fields › Reply To: Show Empty Fields
you work with flexible fields, they can be repeated multiple times and with a own order. normally it doesn’t make sense to add a non-existing layout (if it is even possible)
what you do with your code is to display for each flexible layout that is not neck to display the alternate content.
if you try to display the overlay when image or file is not filled out (but neck flexible field is chosen than you had to do the if/else loop inside neck)
something like this
<!-- Image Start -->
<?php $image = get_sub_field('preview_prop_neck');
if( !empty($image) ): ?>
<img class="media-object" width="100px" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php else: ?>
<img class="media-object" width="100px" src="<?php bloginfo('template_directory'); ?>/images/pdo.png">
<?php endif; ?>
<!-- Image End -->
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.