How to prevent dragging dashboard items in WordPress

By default, items found on your WordPress dashboard can easily be dragged around and rearranged.  This comes in handy when you have a lot of content placed on the dashboard and you want to organize your workspace. Nobody likes to work in a messy office, right?

Whatever your reason might be for disabling this function, we will show you the code which will make the rearranging impossible. After you copy and paste this function, you won’t be able to rearrange your dashboard items. Actually, no one using your website on the backend will.

Prevent dragging dashboard items:

  1. Open functions.php file
  2. Copy and paste the following function:
  3. function remove_postbox() {
    wp_deregister_script('postbox');
    }
    add_action( 'admin_init', 'remove_postbox' );
  4. Save changes

If you only want to disable this feature for you authors and other user roles, but leave the power of rearranging dashboard items for yourself, you need a quick code rewrite:

if (!current_user_can( 'manage_options' )) {
function remove_postbox() {
wp_deregister_script('postbox');
}
add_action( 'admin_init', 'remove_postbox' );
}

That’s all there is. If you ever feel like you need to rearrange dashboard items again, simply comment out this function or delete it until you organize the dashboard as wanted. Then you can activate the function again if needed.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *