WordPress:保存或编辑帖子时执行功能
这就是我想要实现的目标: 如果我要添加或编辑帖子,我想运行一个函数,将 post_id、所有自定义字段值和类别 id 放入我创建的其他数据库表中。 我只想知道如何执行这个函数以及如何获取值。
This is what I'm trying to accomplish:
If I'm adding or editing post I want to run a function that puts post_id, all the custom field values and category ids to some other db table I've created.
I just want to know how to execute this function and how to get the values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将以下内容放入主题的
functions.php
文件中。它将在保存和更新时运行。既然你有帖子ID,你就可以做任何你想做的事。Put the following in your
functions.php
file of your theme. It will run on both save as well as well update. Since you have the post ID, you can do whatever you want.这是发射了两次。
添加
抑制修订为我解决了这个问题。也许你想压抑更多……
This was firing twice.
Adding
to suppress revision solved it for me. Maybe you want to suppress more...