title: Make product posts draft if post meta field equals value
body: <p>I have a function which runs daily which I want to check if a post is expired (based on a custom postmeta field) and if so set the post status to draft. I think I have the principle right but there's something probably pretty wrong with the syntax which isn't making it work correctly. This is the function so far: </p>
  
  <pre><code>function make_product_draft( ) {
      global $wpdb; 
      $sql = "
      UPDATE $wpdb-&gt;posts 
      INNERJOIN $wpdb-&gt;postmeta on $wpdb-&gt;posts.ID = $wpdb-&gt;postmeta.post_id
      SET $wpdb-&gt;posts.post_status = 'draft' 
      WHERE $wpdb-&gt;posts.post_type = 'product' AND $wpdb-&gt;posts.post_status = 'publish' AND $wpdb-&gt;postmeta.post_type = 'expired'
      ";
      $wpdb-&gt;query($sql);
  }
  </code></pre>
  
  <p>I think where I am going wrong is when I do this: $wpdb->posts.ID? I am not sure what the correct syntax is. Your help is much appreciated :)</p>