WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Adding submit or update button to custom metabox?

I added a Meta Box Like So:

add_action('add_meta_boxes', function() {
    add_meta_box('CNMeta', 'Custom MetaBox', 'CNCustomMeta', 'post');

I also added a thing that saves all of the meta information like this:

add_action('save_post', function($id) {
    if(isset($_POST['CNPrice']) ) {
        update_post_meta( $id, 'CNDetails', strip_tags($_POST['CNDetails']) );

So they can save it by updating the post, it would be nice if I could add a submit button at the bottom of the meta box that also updates the post (and doesn't popup a warning saying "You are about to leave this post unsaved"

How would I do something like that?

share|improve this question

marked as duplicate by Brady Aug 30 '12 at 9:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

See how the default submit button does, and mimic that? – Ashfame May 6 '12 at 8:39
Take a look on this answer: Adding submit or update button to custom metabox?. – Max Yudin May 7 '12 at 13:21
That answer worked good! – Talon May 7 '12 at 18:46
up vote 1 down vote accepted

To update a post.

<input id="publish" class="button-primary" type="submit" value="Update" accesskey="p" tabindex="5" name="save">
share|improve this answer
That's the first thing I tried actually. It's not a good solution because if the user makes changes to the post and then the user updates the custom meta box (a very common occurence) it will popup a warning message saying that they haven't saved their post. – Talon May 7 '12 at 18:38

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