Empty icon objects return as ‘null’ when using “get_sub_field()”
-
Hi, Matt!
I’ve run into an issue where calling the icon with “get_sub_field(‘icon’)” returns the string “null” when the field is left empty in the admin. I’ve resorted to using “get_sub_field(‘icon’) != ‘null’)” in my template so that this ‘null’ string isn’t displayed to my users when icons aren’t desired.
This field was likely created in a v1.x.x of your plugin. I saw this referenced in another thread here in your support area, so I’m curious if that has something to do with the issue?
I feel like some code is not functioning properly, as a “get_sub_field(‘icon’)” should return “false” if it is not set, instead of returning a string of ‘null’.
Thanks for your great plugin, and your help on this issue! It’s not affecting my users directly now thanks to my patch, but I do need to find a proper permanent solution, whether that is a plugin update or a template change on my end if your plugin (or ACF) has changed how the “get_sub_field” functions.
Best,
Ian
- The topic ‘Empty icon objects return as ‘null’ when using “get_sub_field()”’ is closed to new replies.