douweng1935 2018-09-06 10:53
浏览 39

如何在Wordpress Admin中找到操作更新帖子?

Im kinda new with wordpress. I wonder where is the code excute the action Update when I hit the button "Update" in wP admin when I edit post ? Because I want to modify some information before it update to DB.

  • 写回答

1条回答 默认 最新

  • doubei2340 2018-09-06 11:03
    关注

    You don't really need to know where the code is located, Wordpress provides hooks for almost every action we do.

    So in your case, when a post is updated there are some hooks that are fired.

    1. pre_post_update Fires immediately before an existing post is updated in the database.

    2.transition_post_status Fires when a post is transitioned from one status to another.

    The 1st one

    do_action( 'pre_post_update', int $post_ID, array $data )
    

    You can run the pre_post_update hook and do whatever you need to do on the post.

    https://developer.wordpress.org/reference/hooks/pre_post_update/ https://developer.wordpress.org/reference/hooks/transition_post_status/ https://codex.wordpress.org/Plugin_API/Action_Reference/post_updated

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)