Support

Account

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

Solved

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

    • pooya

    • June 22, 2019 at 9:47 pm

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

    • James

    • July 28, 2019 at 4:11 am

    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; ?>
    • pooya

    • August 3, 2019 at 5:54 am

    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.

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.