Home › Forums › General Issues › Update sub field, then get value › Reply To: Update sub field, then get value
Hi al, Thanks for your reply, I managed to find a trick to solve this problem by using the native WordPress get_post_meta function, the idea is as follow:
$lists = get_field('lists', $post->ID);
$len= 0; // To get the number of rows
foreach ($lists as $key => $list) {
update_sub_field(array('lists', $key, 'field'), 0, $post->ID);
$len++;
}
$result = array();
for($i= 0; $i < $len; $i++) {
$result[$i]= array(
"field" => get_post_meta($post->ID, "lists_".$i."_field", true),
);
}
var_dump($result);
You have just to take a look about how ACF name the post meta fields here: http://www.advancedcustomfields.com/resources/querying-the-database-for-repeater-sub-field-values/
Regards
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.