I'm building a Directory in Wordpress, and using Advanced Custom Fields for the client to populate the directory entries. One of the sections is for Social Media icons.
Using the following code, I can check to see if any of the three fields (twitter / facebook / linked-in) is empty, and if empty to not show an icon:
<li><?php if(get_field('twitter') != ""): ?><a href="<?php the_field('twitter'); ?>" class="twitter">Twitter<span></span></a></li>
<?php else: ?><?php endif; ?>
<li><?php if(get_field('facebook') != ""): ?><a href="<?php the_field('facebook'); ?>" class="facebook">Facebook<span></span></a></li>
<?php else: ?><?php endif; ?>
<li><?php if(get_field('linked_in') != ""): ?><a href="<?php the_field('linked_in'); ?>" class="linked">Linked In<span></span></a></li>
<?php else: ?><?php endif; ?>
I need help in working how to check to see if all 3 fields are empty to show additional text. (E.g There are no social icons to display).
I currently have:
<?php if(get_field('linked_in') && get_field('twitter') && get_field('facebook') != ""): ?>
<span class="small">There are no Social Media links to display</span><?php endif; ?>
However, using this code shows nothing when all 3 fields are empty - but shows the text 'There are no social...' when all 3 fields have values instead!
I'd be very appreciative if anyone can send me in the right direction on this one. I'm pretty much still a newbie, but trying hard to learn so please be gentle!