开发者

wordpress - catching save event with a plugin

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜