get_the_terms inside save_post gives old terms

This issue shouldn’t happen if you’re using the classic editor, however, if you’re using the block/Gutenberg editor which uses the REST API, then that issue can be fixed by using the wp_after_insert_post hook instead. Excerpt from https://make.wordpress.org/core/2020/11/20/new-action-wp_after_insert_post-in-wordpress-5-6/: The new action wp_after_insert_post has been added to WordPress 5.6 to allow theme and plugin developers to run …

Read more

My custom title gets duplicated at every save or post update

First of: Your custom title suffix getting duplicated might not be what you want to happen, but is expected behavior as per your code sample. The save_post action hook runs everytime a post (or page) is created or updated. Hence your callback runs everytime. Let me offer two solutions: 1 Use the wp_insert_post action instead …

Read more