Home › Forums › Add-ons › Repeater Field › get_post_meta for a repeater field › Reply To: get_post_meta for a repeater field
John, your solution is right and worked for me, but there is a typo in the for(…) parameters. Since this post is the first to come up in Google for the issue I hope this helps some people:
$repeater_value = get_post_meta($post_id, 'repeater_field_name', true);
if ($repeater_value) {
for ($i=0; $i<$repeater_value;/*<-fixed*/ $i++) {
$meta_key = 'repeater_field_name_'.$i.'_sub_field_name';
$sub_field_value = get_post_meta($post_id, $meta_key, true);
}
}
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.