How to deregister default styles in the WordPress admin area

To deregister default styles in the WordPress admin area, you can use the admin_enqueue_scripts action hook and the wp_deregister_style() function. Follow these steps:

  1. In your WordPress admin dashboard, go to “Appearance” > “Theme Editor.”
  2. In the right sidebar, locate and click on the “functions.php” file.
  3. Add the following code snippet at the end of the file:
function my_theme_deregister_admin_styles() {
    // Deregister the default styles you want to remove
    // For example, to deregister the 'dashicons' style:
    wp_deregister_style('dashicons');
}
add_action('admin_enqueue_scripts', 'my_theme_deregister_admin_styles');

This code snippet creates a function called my_theme_deregister_admin_styles() that deregisters the specified default styles in the WordPress admin area. In the example above, the ‘dashicons’ style is deregistered. Replace ‘dashicons’ with the handle of the default style you want to remove.

  1. Click “Update File” to save the changes.

Now, the specified default styles will be deregistered in the WordPress admin area.

Note that deregistering default styles may cause visual issues or break certain functionality in the admin area. Be sure to test your changes thoroughly on your staging site or local development environment before applying them to your live site.

Remember to always backup your files before making any changes, and test your changes on a staging site or local development environment before applying them to your live site.

Leave a Reply

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