Anyone know how to disable this functionality so the meta boxes can't be repositioned?
I had the same problem, and Google lead me here. Unfortunately none of these answers helped, but I ultimately figured out the answer, and it's quite easy!
Essentially this just disables jQuery UI Sortable, which powers the metabox dragging functionality (postbox.dev.js:64). This also switches the cursor on the metabox handle to a standard mouse pointer instead of a move cursor (idea courtesy of brasofilo below).
Hope this helps!
Edit: I should add that it's probably worth following some of the other advice here and disabling the saving of the metabox order. It will prevent confusion on the off-chance something gets mistakenly re-enabled.
Second edit: For the benefit of future generations (and future Google searchers), this fix was tested on WordPress 3.3.1. I can't speak to other versions!
The fastest way is deactivate the JS for this function. But i think, it is better when you also deregister the style for the box and init a custom style without the effects for the mouse and the open/close icon on the meta boxes.
... and this CSS :
I used that code to take advantage of the meta boxes but without the drag-and-drop and the open/close functions.
I noticed this question has remain unaswered, insofar as the asker not selecting a correct answer.
Jan gave a working example of stopping the metabox re-ordering being saved over Ajax, whilst others gave suggestions relating to the JS.
As far as i understand it all you want to do is disable dragging, nothing more. To do that you'll need two things, firstly a function to intercept the ajax saving action, but secondly you also need to stop the JS dragging and dropping without killing of functionality anywhere else in the page, whilst also being to do it selectively for a post type or particular metabox.
Using Jans function and some jQuery we can do that without totally killing other functionality the postbox script creates, like so..
PHP Code for theme functions file or plugin file
Uncomment 1 of the appropriate lines to make the enqueue work.
Very basic jquery that removes the metabox sortable class from appliable elements, this prevents the dragging.
As you can see i've added in 1 example post type to add the code, book in this case. However you mentioned wanting to also have the possibility of disabling it for specific metaboxes.
It can be done, there's just a few small side-effects one of those being, that by removing classes from given metaboxes to prevent dragging, you do also prevent the toggle function working(ie. the metabox title toggle functionality).
That said, it can be done...
First, you'd update the
Again, noting you need to uncomment the applicable
The array inside the localize call is what determines which metaboxes to disable, the empty 0 keyed item is there purposely because the localize script function strips any 0 keyed indexes in the array.
Second, the new JS file referenced in the above tweaked enqueue function.
Only thing you need do is determine the ID for the metaboxes you want to hide, and pass them into the array that sets the disabled metaboxes(in the
In any case, i hope that's helped address the original question.