Title: Modify post meta before inserting new post
Last modified: August 21, 2016

---

# Modify post meta before inserting new post

 *  [hanbr](https://wordpress.org/support/users/hanbr/)
 * (@hanbr)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/modify-post-meta-before-inserting-new-post/)
 * Hi!
 * I’m trying to modify the post meta before inserting a new post. I can’t finda
   anyway to do this. The closest I get is the wp_insert_post_data filter, but there
   I think I can only modify the $data array and not the $postarr array where the
   post meta are located:
 * add_filter( ‘wp_insert_post_data’ , ‘modify_post_meta_before_insert’ , ’99’, 
   2 );
    function modify_post_meta_before_insert( $data , $postarr ) { if($data[‘
   post_type’] == ‘special_post_type’) { // Here I would like to modify $postarr//
   $postarr[‘post_meta_type’] = … } return $data; // Here I can only return $data
   and not $postarr ? }

Viewing 1 replies (of 1 total)

 *  [Hamsterliciousness](https://wordpress.org/support/users/hamsterliciousness/)
 * (@hamsterliciousness)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/modify-post-meta-before-inserting-new-post/#post-4367569)
 * I had the same problem and it looks like the only solution is to edit the values
   in the $_POST array directly.

Viewing 1 replies (of 1 total)

The topic ‘Modify post meta before inserting new post’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [Hamsterliciousness](https://wordpress.org/support/users/hamsterliciousness/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/modify-post-meta-before-inserting-new-post/#post-4367569)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
