Site icon Hip-Hop Website Design and Development

ACF – get fields from group

i’ve been utilizing this code to get all fields from a selected group:

<?php
$GroupOrPostSlug = 'acf_specialgroup';
//or insert the ID of your fields Group.
$groupID='';



international $wpdb;
if (empty($groupID))
{$groupID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name =  '$GroupOrPostSlug' ");}
if (empty($groupID))
{$groupID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title =  '$GroupOrPostSlug' ");}

$custom_field_keys = get_post_custom_keys($groupID);
foreach ( $custom_field_keys as $key => $fieldkey )
{
    if (stristr($fieldkey,'field_'))
    {
        //echo $key . " => " . $fieldkey . "<br />";
        //echo $discipline['label'] . ': ' . $discipline['value'];
        //echo $fieldkey . "<br />";
        $discipline = get_field_object($fieldkey, $groupID);
        echo $discipline['label'];

    }
}
?>

nevertheless it shows solely fields’ names. doesnt there exist a easy hook/operate, one thing like this: get_all_fields_from_group($id)