• 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

    (@julialasarte)

    Have you checked here? It’s a pretty complete guide.

    Thread Starter stuk88

    (@stuk88)

    yup already checked there…
    i didnt able to find any “new_post” like, hook.

    Thread Starter stuk88

    (@stuk88)

    There is any way to hook to a new post creation?
    Anyone?

    popper

    (@julialasarte)

    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

    (@stuk88)

    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

    (@kif0rt)

    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.