title: wordpress update multiple posts post meta
body: <p>I am trying to update multiple posts post meta at the same time. I have the following query:</p>
  
  <pre><code>&lt;form action="" method="post"&gt;
  &lt;?php 
  
  $variations = new WP_Query();   
  $variations-&gt;query(array('showposts' =&gt; -1, 'post_type' =&gt; 'product_variation' )); while ($variations-&gt;have_posts()) : $variations-&gt;the_post(); ?&gt;
  
  &lt;input name="regular_price[]" type="text" value="&lt;?php echo get_post_meta(get_the_id(), "_regular_price", true); ?&gt;" /&gt;
  &lt;input name="sale_price[]" type="text" value="&lt;?php echo get_post_meta(get_the_id(), "_sale_price", true); ?&gt;" /&gt;
  &lt;input name="item_id[]" type="hidden" value="&lt;?php echo get_the_id(); ?&gt;" /&gt;
  
  &lt;?php endwhile; wp_reset_query();?&gt; 
  &lt;input name="save" type="submit" /&gt;
  </code></pre>
  
  <p>I then have the following php to process the data:</p>
  
  <pre><code>&lt;?php
  if (isset($_POST['save'])) {
  
      $ids = $_POST['item_id'];
      $sales = $_POST['sale_price'];
  
  foreach ($ids as $id){
  
      update_post_meta($id,'_sale_price',$sale));
  
  }
  } ?&gt; 
  </code></pre>
  
  <p>For some reason the above does not save correctly. It will only save the last value, and apply this to all post meta. Is there something i am doing wrong?</p>