I'm trying to track down an issue with a plugin. In vanilla WP when you are on the post edit screen (/wp-admin/post.php) what function is getting called to change the post status from draft to publish?

I've looked in that post.php and there is nothing that I'm seeing do it. I'm thinking that it may be some kind of AJAX call and I tried pausing execution to see what's happening when you click that button but I couldn't find anything.

1 Answer 1


Normally, posts are published by the wp_insert_post() function. Essentially, the post_status is changed from draft to publish. Nothing more to it than that, really.

There is also the wp_publish_post() function, which is really only used for scheduled posts. It does the basic job of transitioning a post from "future" to "publish", and also calls the same various action hooks that wp_insert_post() would normally call, so that plugins and other functions which take actions on publishing of posts behave correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.