update_post_meta does not add new revision

Support MB Revision update_post_meta does not add new revision

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #14973
    raphaelraphael
    Participant

    Hello,
    I've enabled MB Revision and it works great when I update a custom field through the admin panel but when I do it programmatically through update_post_meta, the change is not detected so there is no revision added.

    Is it Work As Intended ? Is there another utility function that would trigger the creation of a revision ? Another way to trigger it manually ?

    Thanks !

    #15014
    Anh TranAnh Tran
    Keymaster

    Hi raphael,

    The update_post_meta is the low level API for adding post meta, while the revision stays in higher level of the WordPress app. So, if you use update_post_meta, that's the expected behavior.

    I think trigger the creation of a revision can be done with wp_insert_post. Here is the docs for it: https://wordpress.org/support/article/revisions/#revision-storage-method. Strangely, I couldn't find a programmatic way to create a revision. Probably WordPress doesn't support it yet.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.