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


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:

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

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

You must be logged in to reply to this topic.