Check if new post or update before save_post action

You can achieve this by using the wp_insert_post hook, which is called before the post is saved or updated. Inside this hook, you can check if the post ID exists to determine if it’s an update or a new post. Here’s how you can do it:

        add_action('wp_insert_post', function ($post_ID, $post, $update) {
        if (!$update) {
            // This is a new post
            add_action('save_post', function ($post_ID, $post) {
                // Do something when it's a new post
            }, 11, 2);
        } else {
            // This is an update
            add_action('save_post', function ($post_ID, $post) {
                // Do something when it's an update
            }, 9, 2);
        }
    }, 10, 3);

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino