Home › Forums › General Issues › get_field returns array, field type is text. › Reply To: get_field returns array, field type is text.
Hi @robmehew
Could you try using WordPress sanitize_text_field()
function to do the sanitation just to make sure there’s nothing outside of ACF giving you this “error”. https://codex.wordpress.org/Function_Reference/sanitize_text_field
@tadywankenobi that is weird indeed. So the variable $new is definitely an array all the time? You haven’t declared $new somewhere else as well or use the same field_name for a different meta field on the same post? And the value you’ve set for the checkbox is “set”?
Also, you can try instead of a checkbox field to use a true/false field since that’s pretty much what you want.. It’ll return either true or false (1/0 .. duh 😉 ).
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.