WordPress.org

Ready to get started?Download WordPress

Forums

UPDATE or INSERT (2 posts)

  1. hanifb
    Member
    Posted 7 years ago #

    How do my fucntion in my plugin that is hooked to "save_post" know if its a update or a new post?

  2. microkid
    Member
    Posted 7 years ago #

    Hi,

    I'm struggling with this too.

    The save_post, edit_post and publish_post hooks seem to be oddly ordered.

    First publish_post is triggered, but this happens after the post_status in the database has been set to publish. So no way to see if it's a first time publish or an edit of a published page. Plus everytime a published post is edited publish_post is triggered as well.

    It just doesn't seem logical. One would think publishing a post is something that happens only once. Also, it seems more logical if the publish_post action was triggered after save_post. Having save_post and edit_post both triggered when an existing post is edited is strange too.

    I guess our hopes are on this ticket:

    http://trac.wordpress.org/ticket/4766

Topic Closed

This topic has been closed to new replies.

About this Topic