开发者

wordpress - catching save event with a plugin

开发者 https://www.devze.com 2023-03-22 22:58 出处:网络
i\'m writing my first plugin for wordpress and i have some doubts regarding the hooks. So i want an action to be executed when admin saves a post, and i\'m using (inside a class):

i'm writing my first plugin for wordpress and i have some doubts regarding the hooks.

So i want an action to be executed when admin saves a post, and i'm using (inside a class):

add_action( 'save_post', array($this, 'save_post'));
function save_post(){
    global $wp_query;
    var_dump($wp_query);
}

the problem is that it prints the global variable when admin opens the "create a new post" and it doesn'开发者_StackOverflow社区t when the user saves a post.

I want it to happen the other way around, but i can't find anything in the docs, and i'm completely alone here.

Any help? thanks


I think you're looking for the 'publish_post' action. There's also a 'draft_post' if you need it.

0

精彩评论

暂无评论...
验证码 换一张
取 消