I have alot of custom meta boxes, and the user has to scroll to the top everytime he wants to save the meta info.
Is there a way to put submit buttons at every meta box that does that same as the update button?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityDon't know if i agree with EarnestoDev answer which is more of an opinion then an answer based on facts and not true in all cases, since you can use jQuery to trigger the submit event when a different element is clicked, so just add this js code once
<script>
jQuery('.metabox_submit').click(function(e) {
e.preventDefault();
jQuery('#publish').click();
});
</script>
and in each metabox add:
<input type="submit" class="metabox_submit" value="Submit" />
DON'T DO IT! There's reasons why FORMs have centralized submits. Because there's some processing done behind the screen and one button is safe. Having an extra button in all your Metaboxes will also take up more space.
The easier you make it for the user to press the button, the safer it is to bet he'll forget something. The more difficult it is to submit a post, the more sure you can be he'll review stuff properly.
One button = IMPORTANT. Many buttons = importance demotion.
This is the totally wrong approach to the problem (and this is really a UX question, not a coding one).
When you have many submit buttons, the UX convention is that each button will submit data grouped with it and not any other. This is not how wordpress post editor work as it has only one form and the metaboxes are just for visual effect, not a true separation of forms. Therefor you want only one submit button in order to not to confuse your users.
Now the problem with the button is that it scrolls with the page and gets out of the users field of view and he needs to scroll to see it, but the solution is not to litter the page with tens of buttons, but to either float the button (add some JS to change the css position to fixed when it gets out of view) or add a submit button in the admin bar and I can't find it right now but there used to be a plugin that does it.