Skip to content

Instantly share code, notes, and snippets.

@interactiveRob
Last active November 20, 2023 14:12
Show Gist options
  • Select an option

  • Save interactiveRob/01a1edf0319e77e9b93387244a8a1c82 to your computer and use it in GitHub Desktop.

Select an option

Save interactiveRob/01a1edf0319e77e9b93387244a8a1c82 to your computer and use it in GitHub Desktop.
Wordpress run function when post is saved
<?php
add_action('save_post', function($post_id, $post, $update){
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {// ignore autosave
return;
}
if (!$update) { // ignore Add New post
return;
}
//do something --
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment