I'm trying to implement a "publish" button from a custom post type metabox. Everything actually works fine if I either create a new button and manually call submit() or duplicate the regular submit buttons, except for one thing: if i change the title of the post, I always get the "Confirm Navigation" popup asking me if I want tstay or leave the page. It doesn't do this when using the regular "Update" button though, so there's gotta be a way to stop it, I just can't seem to get a handle on it.

Custom save button using a link:

<a href="#" id="saveChangesButton" class="button-primary alignright">Save</a>

// in ready()
$('#saveChangesButton').live('click', function() {
        return false;           

Custom save buttons trying to mimic the submitdiv's buttons:

<?php if ($_GET['action'] == 'edit') : ?>
    <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Save') ?>" />
    <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="Update">

<?php else: ?>
    <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />

    <input name="publish" type="submit" id="publish" class="button-primary" value="Publish" tabindex="5" accesskey="p">
<?php endif; ?>
  • Post some relevant code along with your questions, please.
    – soulseekah
    Commented Oct 21, 2011 at 5:54
  • added code samples. Either way I create the buttons, if I change the post's title, I get the "Confirm Navigation" dialog when trying to save.
    – flashape
    Commented Oct 21, 2011 at 17:46
  • Have you seen exactly how the publish link originally works? core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/includes/…, I don't see how your code comes close to this. Are you creating those metaboxes with the add_meta_box() function?
    – soulseekah
    Commented Oct 21, 2011 at 18:41
  • All I wanted to do was submit the post from a secondary button, not recreate the entire process. I worked around the issue by disabling autosave for my custom post type and it works fine now.
    – flashape
    Commented Oct 21, 2011 at 19:48

2 Answers 2


You can stimulate click to Update post button like this.. Adding submit or update button to custom metabox?

jQuery('.metabox_submit').click(function(e) {
<input type="submit" class="metabox_submit" value="Submit" />
  • that is actually what I wound up doing....way simpler.
    – flashape
    Commented Apr 23, 2012 at 18:47
  • This doesn't seem to publish a new post though, only update it. Commented Aug 10, 2015 at 17:19

You can add a custom publish button by using jquery.

   <div class = "splw-mbf-banner"></div>  
          jQuery('.splw-mbf-banner').append('<input name="publish" type="submit" id="publish" class="publish-button" value="Publish" tabindex="5" accesskey="p">');

Also, hide the default publish button by using a simple jQuery code...


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.