Home › Forums › Backend Issues (wp-admin) › ACF load_value to Gallery Field › Reply To: ACF load_value to Gallery Field
So, for some reason the json that is stored in the DB is being partially decoded, which is odd.
This value in the DB is obviously a json srting
[{"title":"Slider 47","image":{"attachment_id":"1653"}},{"title":"Image-1","image":{"attachment_id":"1652"}},{"title":"Image-2","image":{"attachment_id":"1651"}},{"title":"Image-3","image":{"attachment_id":"1650"}},{"title":"Image-4","image":{"attachment_id":"1649"}},{"title":"Image-5","image":{"attachment_id":"1648"}}]
But I don’t know why your query would be returning the decoded value or why the value of the slides
index would appear to still be a json value.
You might want to try
foreach ($slider_data as $slide) {
$attachments = json_decode($slide['slides'], true);
if ($attachments) {
foreach ($attachments as $attachment) {
$value = $attachment['attachment_id'];
}
}
}
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.