Check if post is being published for the first time, or is an already published post being updated
Hook into edit_post to catch changes. And take a look at wp_transition_post_status() which is called on inserts and updates: function wp_transition_post_status($new_status, $old_status, $post) { do_action(‘transition_post_status’, $new_status, $old_status, $post); do_action(“{$old_status}_to_{$new_status}”, $post); do_action(“{$new_status}_{$post->post_type}”, $post->ID, $post); } On publish you hook into draft_to_publish, pending_to_publish and auto-draft_to_publish. For edits hook into publish_to_publish. Example A mini plugin that notifies all … Read more