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.
Best wishes
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.