Prevent sorting and dragging of specific postbox metabox

Yes, it is possible to limit the drag and drop functionality of your boxes. All one needs to do is find the right selectors for the specific boxes it wants to target. When you use

$(".meta-box-sortables").[...]

you are targeting all elements in the page with the class of meta-box-sortables. If, however, you add a custom class to any of those boxes, for example custom-class and than change your jQuery script to

$(".meta-box-sortables.custom-class").[...]

the [...] will only execute for the element that has both meta-box-sortables and custom-class classes. You don’t have to use classes, you can also use element ids to select your desired elements. Just like you do in CSS.

Leave a Comment