Support

Account

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>';
     			}
    		}