Support

Account

Home Forums ACF PRO Get Specific Field Group by ID

Helping

Get Specific Field Group by ID

  • I need to be able to get an entire group by ID, any ideas on how to do this using ACF PRO 5.3.0?

    The following used to work on the free version, but does not work on the PRO version. After doing some research in the forums, it appears that the reason may have something to do with ACF versions or the difference between Free and PRO, not really sure.

    <?php

    $group_ID = 327;

    $fields = array();
    $fields = apply_filters(‘acf/field_group/get_fields’, $fields, $group_ID);

    if( $fields )
    {
    foreach( $fields as $field )
    {
    $value = get_field( $field[‘name’], ‘user_’ . $author->ID );

    echo ‘<dl>’;
    echo ‘</br><dt>’ . $field[‘label’] . ‘</dt>’;

    if(is_array($value)) {
    foreach($value as $singleValue){
    echo ‘<dd>’ .$singleValue . ‘</dd> ‘;

    }

    } else {
    echo ‘<dd>’ .$value . ‘</dd> ‘;
    }

    echo ‘</dl>’;
    }
    }

    ?>

    Any help would be appreciated.

    Thank you,

    Sam

  • I just did a search of the ACF Pro code and that hook does not exist, and looking over the differences between 4 & 5 I’m not sure there is anything filter in 5 that does the same thing.

    Instead you can use $fields = acf_get_fields($field_group); in this case you you use the group key for $field_group usually something like group_55fb4bc36306a. There may be other functions as well that can do this. I’m also not sure if this will work with the ID value your using.

    There also may be other functions that could do it but you may need to look into the ACF code.

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

The topic ‘Get Specific Field Group by ID’ is closed to new replies.