admin管理员组文章数量:1389783
Here, I have some code which applies some indexing operations on an external service (Algolia). My purpose, is to index posts in a similar way, as described in their API documentation. For that cause, I have set up two action hooks:
add_action('save_post', 'algolia_save_post', 10, 3);
and
add_action('trashed_post','algolia_trash_post', 10, 1);
While this works as expected, I noticed that, in case metadata are altered, such as permalinks, the data are not updated in the index.
I then tried the update_post_meta
action hook:
add_action('update_post_meta', 'algolia_update_post_meta', 10, 4);
Which seems to do the job well. However, I suspect that update_post_meta is invoked both when metadata fields are altered, but also on save_post
chain.
As I do not want to achieve a double, redundant indexing on article save I would like to ask, is the addition of the indexing code in the update_post_meta
considered always on post save? In that case, I can remove the save_post
hook and keep only this of meta. What I want to avoid, is the loss of index update in any case of the post update operations (excluding auto-save).
My local testing showed that, by adding the code only in the meta hook, everything works well and index gets updated on any field, yet I am not sure if there is an edge case I miss.
While this question involves the usage of an third-part vendor (Algolia), I believe it can be answered by a WordPress expert. Thank you in advance.
本文标签: postsIs updatepostmeta used when savepost action hook is invoked
版权声明:本文标题:posts - Is update_post_meta used when save_post action hook is invoked? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744585981a2614197.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论