Home › Forums › Front-end Issues › Hide Empty Fields on Posts › Reply To: Hide Empty Fields on Posts
The layout is a matter for CSS. It looks like this is supposed to be a list of some kind, so mark it up as such with HTML:
<!– Begin Custom Fields –>
<ul class="amenities">
<?php if ( get_field(‘kitchen’ ) ) : ?>
<li><?php the_field(‘kitchen’); ?></li>
<?php endif; ?>
<?php if ( get_field(‘air_conditioning’ ) ) : ?>
<li><?php the_field(‘air_conditioning’); ?></li>
<?php endif; ?>
<?php if ( get_field(‘dishwasher’ ) ) : ?>
<li><?php the_field(‘dishwasher’); ?></li>
<?php endif; ?>
…
…
<?php if ( get_field(‘handicap_friendly’ ) ) : ?>
<li><?php the_field(‘handicap_friendly’); ?></li>
<?php endif; ?>
</ul>
<!– /End Custom Fields –>
… and then use CSS to lay it out the way you like. For a list displayed in multiple columns you can use the columns CSS module.
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.