Last active
March 29, 2017 15:22
-
-
Save gabelloyd/fdd6d43cf57d5bb8e34689b979977a97 to your computer and use it in GitHub Desktop.
ACF Check if Value is set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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