Skip to content

Instantly share code, notes, and snippets.

@GarySwift
Last active January 14, 2020 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GarySwift/a3533aee587958a59735414535880378 to your computer and use it in GitHub Desktop.
Save GarySwift/a3533aee587958a59735414535880378 to your computer and use it in GitHub Desktop.
Hack to fix 'Undefined index: key' bug
<?php
# line 350
/**
* Hack to fix 'Undefined index: key' bug
*
* @author Gary Swift
*
* @link https://support.advancedcustomfields.com/forums/topic/acf-field-functions-php349-undefined-index-key/
*/
if ( isset( $parent['key'] ) && isset( $parent['ID'] ) ) {//new
// Check local fields first.
if( acf_have_local_fields($parent['key']) ) {
$raw_fields = acf_get_local_fields( $parent['key'] );
foreach( $raw_fields as $raw_field ) {
$fields[] = acf_get_field( $raw_field['key'] );
}
// Then check database.
} else {
if ( isset( $parent['ID'] ) ) {//new
$raw_fields = acf_get_raw_fields( $parent['ID'] );
foreach( $raw_fields as $raw_field ) {
$fields[] = acf_get_field( $raw_field['ID'] );
}
}//new
}
}//new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment