title: How can I get some of a posts meta data whilst it is still inserting?
body: <p>I'm trying to make a function where a child post of a certain post type inherits the same title and slug as its parent. I'm using WP Types to define my post types and their relationships. But I'm having trouble with the below code:</p>
  
  <pre><code>function copy_parent_post_title( $post_id ) {
  
      $new_post = get_post($post_id);
  
      if($new_post-&gt;post_type == 'carnews-adverts') {
  
          $parent_id = get_post_meta( $post_id, '_wpcf_belongs_carnews_id', true );
          $parent_title = get_the_title($parent_id);
          $post_slug = sanitize_title_with_dashes($parent_title);
  
          $post_update = array(
              'ID'           =&gt; $post_id,
              'post_title' =&gt; $parent_title,
              'post_name' =&gt; $post_slug
          );
  
          remove_action( 'wp_insert_post', 'copy_parent_post_title' );
          wp_update_post( $post_update );
          add_action( 'wp_insert_post', 'copy_parent_post_title' );
  
      }
  
  }
  add_action( 'wp_insert_post', 'copy_parent_post_title' );
  </code></pre>
  
  <p>The problem is this line:</p>
  
  <pre><code>$parent_id = get_post_meta( $post_id, '_wpcf_belongs_carnews_id', true );
  </code></pre>
  
  <p>I presume it is because at this point the post's meta data hasn't been inserted into the database yet? If so how can I achieve what I want by accessing the get_post_meta upon inserting a post?</p>
  
  <p>Thanks</p>