How to get duplicate fields in flutter

logo-flutterWhen using flutter it’s a kind of secret how to get duplicate fields out of flutter again. When using getGroupDuplicates like this tutorial recommends you only get the amount of duplicates but you can’t use the amount result in a for() loop unless you never delete a duplicate. When deleting an item and adding a new one the field index will get incremented and knowing the amount of duplicates gets useless. Benoz in the the flutter google group wrote a function and recommends to add it to the Main.php of the flutter plug-in. I disagree because your flutter installation can’t be updated.

Just this inside the loop of wordpress

$result = $wpdb->get_results("
  SELECT meta_value
  FROM $wpdb->postmeta
  WHERE post_id = '$post->ID' and meta_key = 'color'
  ORDER BY meta_id
  ", ARRAY_A );

 if ($result!=''){
   foreach ($result as $value){
     echo $value['meta_value'];
   }       
 }

2 Responses Subscribe to comments


  1. alex

    Thank you for posting this. Quick question. How would I pull in the values for more than one meta_key, sort the results based on meta_id, and populate arrays with the values?

    I have a text field that needs to correspond to an image, and their grouping will be based on the respective order of their meta_id’s…

    feb 03, 2010 @ 22:47


  2. admin

    Just modify the query to something like this.

    $result = $wpdb->get_results(”
    SELECT meta_value, meta_key
    FROM $wpdb->postmeta
    WHERE post_id = ‘$post->ID’ and (meta_key = ‘first_field_name’ OR meta_key=’second_field_name’)
    ORDER BY meta_id
    “, ARRAY_A );

    feb 11, 2010 @ 11:55

Reply