Support

Account

Home Forums General Issues Display all ACF field, except for..

Solving

Display all ACF field, except for..

  • Hi, I use a code to display all the ACF field of a product on the product page. Recently I’ve added a new field group in which I put information about my supplier. I don’t want’t this information to be displayed. It’s for interal use. How can I realize this? My current code is:

    <?php

    $fields = get_field_objects();
    ?>
    <?php if( $fields ): ?>

      <?php foreach( $fields as $field ): ?>

      <?php if( $field[‘value’] ): ?>

    • <?php echo $field[‘label’]; ?>: <?php echo $field[‘value’]; ?>
    • <?php endif; ?>

      <?php endforeach; ?>

    <?php endif; ?>

  • Hello, just change this line:

    <?php if( $field['value'] ): ?>

    to

    <?php if( $field['value'] && $field['label'] !== 'field_label_you_want_to_hide' ): ?>

    Just replace ‘field_label_you_want_to_hide’ with the actual field label.

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

You must be logged in to reply to this topic.