Title: new post hook
Last modified: August 19, 2016

---

# new post hook

 *  [stuk88](https://wordpress.org/support/users/stuk88/)
 * (@stuk88)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/new-post-hook/)
 * Hi every body.
    im trying to write a plugin that will count for any user new 
   posts when added, but i saw just post_publish hook that is activated on post 
   send and on post published status change. is there a hook for just “new post”?
   or is there any way to check if the post published is new or just new to be published?

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

 *  [popper](https://wordpress.org/support/users/julialasarte/)
 * (@julialasarte)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/new-post-hook/#post-1596709)
 * Have you checked [here](http://adambrown.info/p/wp_hooks/version/3.0)? It’s a
   pretty complete guide.
 *  Thread Starter [stuk88](https://wordpress.org/support/users/stuk88/)
 * (@stuk88)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/new-post-hook/#post-1596775)
 * yup already checked there…
    i didnt able to find any “new_post” like, hook.
 *  Thread Starter [stuk88](https://wordpress.org/support/users/stuk88/)
 * (@stuk88)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/new-post-hook/#post-1596801)
 * There is any way to hook to a new post creation?
    Anyone?
 *  [popper](https://wordpress.org/support/users/julialasarte/)
 * (@julialasarte)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/new-post-hook/#post-1596803)
 * [save_post](http://adambrown.info/p/wp_hooks/hook/save_post) Runs whenever a 
   post or page is created or updated, which could be from an import, post/page 
   edit form, xmlrpc, or post by email. Action function arguments: post ID.
 *  Thread Starter [stuk88](https://wordpress.org/support/users/stuk88/)
 * (@stuk88)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/new-post-hook/#post-1596806)
 * yea i know that didnt help me in the first time either..
    my quastion was how
   to check if the saved post was a new post or just an update to an exiting post…
 * I already found a way to check this…
    new post doesnt have any id set to it yet.
   so the code looks like that: `if($post->post_parent == 0 && $post->post_type 
   == 'post' && !$post->ID)`
 * i had to do some other check on deleted post either, because the “delete_post”
   hook run whenever a post data deleted… page or post or revision…
 *  [kif0rt](https://wordpress.org/support/users/kif0rt/)
 * (@kif0rt)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/new-post-hook/#post-1596953)
 * I’m using the next code to handle the first time post publish event.
    WordPress
   3.0+ required. ` add_action( 'publish_post', 'run_when_post_published_first_time',
   10,2 ); function run_when_post_published_first_time($post_id, $post) { // Checks
   whether is post updated or published at first time. if ($post->post_date != $
   post->post_modified) return;
 *  // Place here your code
    }
 * P.S. Sorry for my english.

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

The topic ‘new post hook’ is closed to new replies.

 * 6 replies
 * 3 participants
 * Last reply from: [kif0rt](https://wordpress.org/support/users/kif0rt/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/new-post-hook/#post-1596953)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
