Home › Forums › General Issues › Trying to get group field with get_post_meta inside function.php › Reply To: Trying to get group field with get_post_meta inside function.php
I searched everywhere and nothing found about how to use get_post_meta for group type fields.
After I did some tests found the follwing method:
For example you have a field type group named : group_field_type
Inside the ‘group_field_type’ you have two text type fields : inside_group_one and inside_group_two
to get the two text fields inside the group with get_post_meta in php would be:
$inside_group_one = get_post_meta( get_the_ID(), 'group_field_type_inside_group_one', true ); $inside_group_two = get_post_meta( get_the_ID(), 'group_field_type_inside_group_two', true ); echo $inside_group_one.'<br>'; echo $inside_group_two.'<br>';
You concatenate the group field name with the field name inside the group.
Hope it helps.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Sorry for the issues with ACF's API SSL certificate this morning. We've resolved it and your activations and downloads should be back to normal again. Thanks! ^LG— Advanced Custom Fields (@wp_acf) November 2, 2022
© 2022 Advanced Custom Fields.