您可以使用操作在创建帖子时执行某些操作save_post_
...
$customPostType = "custom";
add_action("save_post_" . $customPostType, function ($post_ID, \\WP_Post $post, $update) {
if (!$update) {
// creation of the custom post
// ...
return;
}
// updating of the custom post
// ...
}, 10, 3);