save_post not triggered when a post is updated

A var_dump() in save_post action doesn’t display any information on the screen. Well, it does only when you are on “Add new” screen. This is due the different sequence of actions that follow when creating a new post or when editing it.

When you click on “publish” or “update” button, there is a request, the post is saved, save_post action is triggered and then you are redirected to the edit screen.

The redirection implies a new request and this new request doesn’t trigger the save_post action, so you can not see any information printed just becasue that action is NOT triggered to generate the screen you are seeing.

If you need to debug save_post action, you can follow this example (it needs WP_DEBUG on and stores the information in the error log file in your server, see error_log() PHP function):

if(!function_exists('log_it')){
 function log_it( $message ) {
   if( WP_DEBUG === true ){
     if( is_array( $message ) || is_object( $message ) ) {
       error_log( print_r( $message, true ) );
     } else {
       error_log( $message );
     }
   }
 }
}

And then, in the save_post callback:

add_action('save_post', 'gh_set_inner_project_order');
function gh_set_inner_project_order() {
    log_it( $parent_id );
    // .... 
}

Remember that you can pass a custom error log file to error_log() function if you want to log the information in a different file from server log. See error_log() docs for more information. For example:

error_log( $var_to_log, 3 , __DIR__ . "/my-log.txt" );