Home › Forums › General Issues › get_field returns array, field type is text. › Reply To: get_field returns array, field type is text.
I got an array being returned from an ACF field after moving onto my production web server. The cause is, I suspect, the bad migration procedure. I re-imported several times the WP database via XML export files one on top of another and again.
As I use Timber/Twig, my code causing errors is {{post.front_page_quick_order|apply_filters('the_content')}}
where the ACF field is front_page_quick_order
.
Making var_dump
I saw clearly that front_page_quick_order
was an array of strings.
Searching in the WP database via PHPMyAdmin for front_page_quick_order
gave me 25 entries in the wp_postmeta
table.
The quick fix 1 was: {{post.get_field('front_page_quick_order')|apply_filters('the_content')}}
– just use the standard ACF function to get the field instead of Timber/Twig shorthand syntax.
The fix 2 (the one I prefer): install WordPress WP-Sweep plugin and clean up the entire DB. Then return the code to the initial state {{post.front_page_quick_order|apply_filters('the_content')}}
.
NB: I tried WPOptimizer with no effect. After WP-Sweep 25 entries become 3.
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.