Support

Account

Home Forums Feature Requests Get field that has specific 'class' or 'id'

Solved

Get field that has specific 'class' or 'id'

  • Is there any solution to get fields that has specific class or id?

  • Hi @pooya

    You can make use of the get_field_objects() function to step through all the fields and display the ones that match your class like so:

    <?php
    $fields = get_field_objects();
    if( $fields ): ?>
        <ul>
            <?php foreach( $fields as $field ): ?>
                <?php if($field['wrapper']['class'] =='your_class'){
                   //do something here
    } ?>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>
  • Thank you so much dear James

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

The topic ‘Get field that has specific 'class' or 'id'’ is closed to new replies.