简体   繁体   English

通过 WP REST API 更新自定义帖子类型时未创建 WordPress 帖子修订

[英]WordPress post revisions not creating when updating a custom post type via WP REST API

I have a few custom post types that have several custom fields created using ACF.我有一些自定义帖子类型,其中有几个使用 ACF 创建的自定义字段。 I have enabled post revisions for the custom post type.我已经为自定义帖子类型启用了帖子修订。

When I editing any field of a custom post using the admin dashboard and saving, the revision is created without any issues.当我使用管理仪表板编辑自定义帖子的任何字段并保存时,创建的修订版没有任何问题。

When I edit or update any field of the same post via WP REST API, the values are getting updated but revision history is not getting created.当我通过 WP REST API 编辑或更新同一帖子的任何字段时,值正在更新但未创建修订历史记录。

It seems the only way revision history is created when using the dashboard and not via the REST API.似乎是使用仪表板而不是通过 REST API 创建修订历史记录的唯一方法。

Is there a way to make it create revisions when updating or creating custom post type posts via REST API?在通过 REST API 更新或创建自定义帖子类型帖子时,有没有办法让它创建修订版? Any hacks or hook I can use?我可以使用任何黑客或钩子吗?

Thanks.谢谢。

试试这个:

add_action('post_updated', 'wp_save_post_revision', 10);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM