Skip to content

Instantly share code, notes, and snippets.

@gabelloyd
Last active March 29, 2017 15:22
Show Gist options
  • Save gabelloyd/fdd6d43cf57d5bb8e34689b979977a97 to your computer and use it in GitHub Desktop.
Save gabelloyd/fdd6d43cf57d5bb8e34689b979977a97 to your computer and use it in GitHub Desktop.
ACF Check if Value is set
// ACF Fields, we want to check if the values being returned are arrays
// We allow this multiple choice field to be blank in the admin, so the $value can return null, which is not an array.
// If we don't check if $value is not there, we get an error with the implode() function
$section_top_bottom_padding_array = get_sub_field_object('section_top_bottom_padding');
$value = $section_top_bottom_padding_array['value'];
if (is_array($value)) {
$section_top_bottom_padding_array_output = implode(" ", $value);
} else { // need to declare null if the array is empty
$section_top_bottom_padding_array_output = null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment