How to force function to run as the last one when saving the post?

add_action has a priority parameter which is 10 by default, you can increase that to load your function late.

Change add_action( 'save_post', 'do_custom_save' );

to

add_action( 'save_post', 'do_custom_save', 100 );

Now the priority is to set to 100 and will load quite late and will allow other function associated to load before this function is executed.

For more details check the function reference for add_action.

Leave a Comment