Home › Forums › General Issues › How to get field data from a group inside a group › Reply To: How to get field data from a group inside a group
I like to add a helper function to my themes…
if ( function_exists( 'get_field' ) ) {
function get_group_field( string $group, string $field, $post_id = 0 ) {
$group_data = get_field( $group, $post_id );
if ( is_array( $group_data ) && array_key_exists( $field, $group_data ) ) {
return $group_data[ $field ];
}
return null;
}
}
Usage: <?php echo get_group_field( 'album_group', 'album_information' ); ?>
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.