Title: wp_insert_post
Last modified: August 20, 2016

---

# wp_insert_post

 *  Resolved [chacha2000](https://wordpress.org/support/users/chacha2000/)
 * (@chacha2000)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/wp_insert_post-3/)
 * Hi, on this page [http://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post](http://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post)
   it says it’s only called once “wp_insert_post is called with the same parameters
   as Save_post, but is only called for new posts, after save_post has run. “
    But
   it’s actually also called each time i update a post… Does anyone know if it’s
   a bug? Is there a hook to add an action when a post is inserted for the first
   time only (for real)? (when the post is inserted into the database and given 
   its ID) Thanks !

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Chris Olbekson](https://wordpress.org/support/users/c3mdigital/)
 * (@c3mdigital)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/wp_insert_post-3/#post-3457888)
 * The error is on the unfinished codex page you linked to.
 * the wp_insert_post action hook is run anytime a post is updated or created. There
   is not a specific hook that runs when a post is first inserted into the database.
   There are specific hooks that run only on update which you can check to see if
   they have been run in your function.
 *     ```
       add_action( 'wp_insert_post', '_only_on_new' );
       function _only_on_new( $post ) {
            $action = did_action( 'pre_post_update' );
            if ( 0 === $action ) {
               //New post do something here...
           }
       }
       ```
   
 * Also to note is that the only time this happens is when you click the new button.
   That is when the post is first saved and an ID generated.
 *  Thread Starter [chacha2000](https://wordpress.org/support/users/chacha2000/)
 * (@chacha2000)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/wp_insert_post-3/#post-3457903)
 * Thanks for clearing that up ! Problem solved !

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘wp_insert_post’ is closed to new replies.

## Tags

 * [wp_insert_post](https://wordpress.org/support/topic-tag/wp_insert_post/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [chacha2000](https://wordpress.org/support/users/chacha2000/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/wp_insert_post-3/#post-3457903)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
