Home › Forums › Add-ons › Flexible Content Field › get_post_meta for a repeater field in a flexible content field? › Reply To: get_post_meta for a repeater field in a flexible content field?
Hi James,
Thank you. I figured out it saved its data like this. The thing I’m struggling with is automatically finding the correct number. This is the code I currently have:
$repeater_value = get_post_meta($item->object_id, 'flexibele_content_1_menukaart-repeater', true);
if (1 == $depth and $repeater_value){
for ($i=0; $i<$repeater_value; $i++) {
$meta_key = 'flexibele_content_1_menukaart-repeater_'.$i.'_categorie';
$sub_field_value = get_post_meta($item->object_id, $meta_key, true);
$sub_field_link = (str_replace(' ', '-', strtolower($sub_field_value)));
$item_output .= '<a class="sublink" href="' . esc_attr( $item->url ) .'#'. $sub_field_link .'">';
$item_output .= $sub_field_value;
$item_output .= '</a>';
}
}
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.