Home Forums Front-end Issues Hide empty fields


Hide empty fields

  • On the front-end, in building out a template file for a custom post type, how do I hide empty fields?

    I’m experimenting with calling the data in different ways using different functions you’ve provided including


    Right now, I’m using the bulk display of get_field_objects() but as I learn and go along, I’m probably going to code out the template using the_field for each of the fields, but how to prevent empty fields from being displayed?

  • As an update to this, this is the snippet I’m currently using, but it is not working.

    <?php $fields = get_field_objects();
    	if( $fields != "")
    		foreach( $fields as $field_name => $field )
    		  echo '<div class="single-custom-field">';
    		  echo '<h2>' . $field['label'] . '</h2>'; echo $field['value'];
    		  echo '</div>';
    • Elliot

    • September 10, 2013 at 10:56 am

    Hi @prometheus Fire

    You can read about ‘hiding empty fields’ here:


  • That’s right on the money. Thank you for the quick reply!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.