Support

Account

Home Forums Backend Issues (wp-admin) Remove empty fields?

Unread

Remove empty fields?

  • I’m currently using the following code to show the custom fields on my posts. Unfortunately, it shows the field labels for fields that don’t have values. How can I prevent this from happening? Thanks in advance! ` <div class=”custom_fields”>
    <?php $fields = get_field_objects();

    if( $fields )
    {
    foreach( $fields as $field_name => $field )
    {
    echo ‘<ul>’;
    echo ‘<div class=”custom-title”>’;
    echo ‘<li><h5>’ . $field[‘label’] . ‘</h5>’;
    echo ‘</div>’;
    echo ‘<div class=”custom-value”>’;
    echo $field[‘value’];
    echo ‘</div>’;
    echo ‘</li></ul>’;
    }
    }
    ?> </div>`

Viewing 1 post (of 1 total)

The topic ‘Remove empty fields?’ is closed to new replies.