[wp-hackers] Single Action hook for _new_ posts of any type?

Andrew Nacin wp at andrewnacin.com
Thu May 6 20:48:07 UTC 2010


wp_transition_post_status().

On Thu, May 6, 2010 at 4:41 PM, Peter Adams <peter at oncefuture.com> wrote:

> Folks -
>
> I'm looking to get two hooks to fire when:
>
> A) a user creates a _new_ post of any type
> B) when a user edits a post of any type
>
> Found that "edit_post" is perfect for case B but that the "save_post" and
> "wp_insert_post" hooks are problematic for A because they also fire when
>  "edit_post"  fires (as they should).
>
> I was going to turn to a variable hook like "publish_post" but  since the
> hook name uses $post->post_type in the construction of the name I would have
> to setup hook ahead of time or all different post types - which isn't going
> to work for posts with custom types that i don't know about.
>
> So my question is...
>
> is there a single hook like "edit_post" that is fired ONLY when a new post
> of any type is created and passes the post object as or an id as a param so
> i can get at post's type?
>
> Thanks,
>
> -P-


More information about the wp-hackers mailing list