How can you receive the most recent permalink or terms of the newly saved post?

When using the Gutenberg Block Editor the normal hooks for saving a post don't have the same behavior as with the classic editor.

For example, if you hook into the save_post-hook the $permalink and the $categories will not return the new value, but instead the old value. Which is not the behavior that I expected from the classic editor.

add_action( 'save_post', 'custom_save_post', 10, 3 );

function custom_save_post( $post_id, $post, $update ) 
{
  $permalink = get_permalink( $post_id ); 
  $categories = get_the_terms( $post_id, 'category' );
}

How can I make it work so that I can retrieve the pre-updated permalink and the post-updated permalink?

Topic block-editor bug save-post terms permalinks Wordpress

Category Web


When using the Gutenberg Block editor you need to use different hooks to get the expected behavior.

credits: @SallyCJ

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.