0

Is it possible to move the publish button out of the publish metabox, completely remove the metabox and then put the publish button inside the custom field group? Ask if you need more information, I am not really sure what to say other than what I have.

Here is what I am aiming for in pictures.

From this: enter image description here

To this: enter image description here

Or if that is to demanding then just this: enter image description here

1 Answer 1

0

Try this:

<div class="my-metabox">
    <!-- This is your metabox HTML -->

    <-- Add this button somewhere: -->
    <button id="my-submit" class="button button-primary button-large">Submit</button>
</div>

Add this JavaScript snippet however you want only to this screen (either by checking the post type and enqueue this in the admin footer or output it directly along with your metabox HTML):

<script type="text/javascript">
    jQuery(function($) {
        // You can substitute this with a CSS rule somewhere:
        // <style type="text/css"> #submitdiv { display: none } </style>
        // if you wish to avoid the hiding 'flicker'
        $('#submitdiv').hide();

        $('#my-submit').on('click', function(ev) {
            ev.preventDefault();                
            $('#publish').trigger('click');
        });
    });
</script>
4
  • Sorry for being a complete knobhead, but what I am trying with your code is to put it in edit-form-advanced.php, but whenever I try to echo the html that you have written out it corrupts the page and it turns white, and everything is gone. What am I doing wrong? Where should I put the code if just want the button to appear under the fields, also can you just move the existing publish button? Complete newbie here. Commented Jul 11, 2015 at 10:44
  • Also a completely different question, do you know where the css stylesheet for the submitbox or the submitbutton is located? Is there anyway to locate this easily? Commented Jul 11, 2015 at 10:48
  • You shouldn't edit the core files. Use the API instead. In your case you want the add_meta_box function. Read that page patiently and carefully. Also, there are numerous tutorials out there on how to add a simple metabox. Again, do not modify core files for you are bound to introduce conflicts and also every change will be overwritten when upgrading WordPress.
    – webtoure
    Commented Jul 11, 2015 at 11:00
  • Woav, thanks you just saved me a lot of time, I will read that, and stop editing in core files. Thanks. Commented Jul 11, 2015 at 11:08

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.