试图让 wordpress 挂钩 post_updated 工作 [英] Trying to get wordpress hook post_updated to work

查看:28
本文介绍了试图让 wordpress 挂钩 post_updated 工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让它工作 - 不确定我做错了什么 - 但我试图使用 post_updated 钩子而不是 save_post - 因为我希望在帖子更新后插入这些值,以便我可以从其他自定义字段.

I cant get this to work - not sure what Im doing wrong - but Im trying to use post_updated hook instead of the save_post - as I want these values to be inserted after the post has been updated so I can retrieve values from the other custom fields.

 function update_meta ($ID = false, $post = false) {
  update_post_meta($ID, 'rest_long', 'Test 1');
  update_post_meta($ID, 'rest_lat', 'Test 2');
}

add_action('post_updated', 'update_meta');

推荐答案

我已经弄明白了 - 我使用了一种行为不同的自定义帖子类型.我也切换到 save_post,现在一切正常.

Ive figure this one out - I was using a custom post type which behaves differently. Ive also switched to save_post and all is working now.

这篇关于试图让 wordpress 挂钩 post_updated 工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆