Support

Account

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' ); ?>