Support

Account

Home Forums Front-end Issues Getting Field Group ID when registering with acf_add_local_field_group

Solving

Getting Field Group ID when registering with acf_add_local_field_group

  • Hi,

    I’ve registered a new field group using the acf_add_local_field_group function – however I can’t access the Field Group via the back-end to find the Field Group ID. I need to be able to loop through the Field Group to print out the individual fields, as there are 100+ of them.

    Any other way of grabbing the Field Group ID? I’ve thought of querying the database, but hoping for a cleaner method.

    Thanks

  • A field group registered locally does not have an ID and is not stored in the database. The ID is the post ID of the field group.

    How are you trying to get this field group by the ID?

    Try using the group key.

  • Hi John,

    Thanks for your reply.

    I have now solved this issue. As I was trying to access fields associated with a post, I used the ACF get_fields function, using the Post ID as a parameter. Posted my snippet below for anyone interested.

    
    <?php 
    $singleFields = get_fields($postID);
    foreach( $singleFields as $name => $value ) :
    ?>
    
    <div>
    .....
    </div>
    
    <?php endforeach; ?>
    
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.