• As we know that Gutenberg sends two requests when we hit the Publish/Update button:

    1. Request to WP REST API to create/update the post
    2. Request to post.php to save/submit the metaboxes

    save_post is triggered by both the requests. How do I know inside the save_post callback that the post is created/updated via Gutenberg, preferably in the second request? This is to avoid the double effect of the hook.

    I know some would suggest to add some meta value in the first request and use it to short-circuit the second callback or use a transient in a similar way. Filling up the meta table with useless data is not a good idea and transients don’t look to be a better solution IMHO.

    Is there a consistent query argument or a header that can be relied upon? I couldn’t find any such thing in the two requests.

  • The topic ‘How to differentiate b/w REST and POST requests of Gutenberg inside “save_post”’ is closed to new replies.