Support » Plugins » publish_post without trigger on edit

  • Resolved alexmat


    Is there any action like publish_post that does not trigger when a published post is edited?

    I send out an e-mail whenever a post is published, but don’t want it sending e-mails when a post that was published is edited.


Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Yep. I think it would be draft_to_publish, but you may want to test that theory. It might be new_to_publish instead.

    Thank you so much. “new_to_publish” works like a charm. Although it wasn’t documented in the link you pointed me to, but that was also useful.


    Does new_to_publish happen when scheduled posts get published as well?

    I’m looking for an action that is called whenever a post which was not previously published becomes published, but not when an existing post is edited.

    @jeckman no you’ll probably want something like this:

    add_action('future_to_publish', 'function_name');

    Thanks @ajaswa – but does future_to_publish also catch posts that were not scheduled but published immediately?

    Sorry if I’m missing something here – but the Post Status Transitions docs aren’t clear to me.



    together cover all these cases:

    • New post, write, publish immediately
    • New post, save a draft, edit draft, publish
    • New post, schedule for publishing, publish when time arrives, regardless of whether it has been saved as draft and edited or not

    Might be easier just to use:


    Since the “false positives” of having it occur when posts are edited is probably minimal impact as opposed to potentially missing a post.


    You are right the docs really suck on this subject. I’ve only figured this out by trial and error.

    To cover all 3 of your cases you’ll probably want:


    Something else about this method is from what I can tell it applies to both posts and pages.
    I’ve found publish_post to be more annoying then helpful. There really ought to be a hook for just new publishes and one for edits.

    When you use add_action(‘publish_post’,’function_name’);

    does function_name run BEFORE the post is actually published, sometime during the various actions, or after it is all complete and done?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘publish_post without trigger on edit’ is closed to new replies.