How to check what kind of saving it is?

There are hooks specifically for this, actually. The codex has a pretty good overview. Essentially every time WordPress saves a post (which it does through wp_insert_post) or alters the status of the post, it calls wp_transition_post_status which looks like this: <?php // in wp-includes/post.php 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); … Read more

Check if the value of a field has changed on save_post

Usually there is no way to check if the meta data is updated or not, but you can use updated_postmeta and added_post_meta to get kinda similar functionality. Please have a look at the below code- add_action( ‘updated_postmeta’, ‘the_dramatist_updated_postmeta’, 10, 4 ); add_action( ‘added_post_meta’, ‘the_dramatist_updated_postmeta’, 10, 4 ); function the_dramatist_updated_postmeta( $meta_id, $object_id, $meta_key, $meta_value ) { … Read more

WordPress Gutenberg get page template value when post updated?

So I found a solution. There are 4 hooks that can be used to accomplish this depending on the exact needs. The hooks are from wp-includes/meta.php in functions update_metadata() and add_metadata(). Hooks: update_postmeta updated_postmeta add_post_meta added_post_meta These are called at different states and from the names it is pretty self self explanatory. add_post_meta and update_postmeta … Read more