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

How do I create a "publish" button to put in a custom metabox?

Or if you can point me to the code that creates the current publish box, that'd help me out.

-attempting to simplify my custom post type-

share|improve this question
Apparently you can just copy and paste the HTML from the major-publishing-actions div but you lose some javascript interaction as the page tries to reload instantly (even though it posts on reload) instead of working the ajax (with the spiny wheel next to publish). Still looking for the perfect solution. – Dave Jan 28 '12 at 0:40
up vote 0 down vote accepted

Dig in Core

All admin UI pages use a core function for a reason:

submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL );

There's also get_submit_button() in case you want to return instead of print the button.

share|improve this answer

<button type="submit">Your Text</button> should about do it for you...it's just a submit button, nothing special. It's generated by post_submit_meta_box(), specifically submit_button( __( 'Publish' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) );.

share|improve this answer
Oh nice. Thanks for the PHP code there. Any idea how to include the original AJAX functionality? – Dave Jan 28 '12 at 0:43
I'd guess it's tied to the class or the ID, here's the html <input type="submit" name="publish" id="publish" class="button-primary" value="Publish" tabindex="5" accesskey="p"> Mimic that exactly and see if you can get it to just WORK, then start working backwards and see if you can find the source of what makes it work...probably be a heck of a lot faster than digging through all the JS lol...if I had to take a hack, I'd say that its #publish that does it. – mor7ifer Jan 28 '12 at 0:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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