What are WordPress must-use plugins?
![PHP code](https://wcanvas.com/wp-content/uploads/2023/09/mu-plugins-HERO-1024x536.jpg.webp)
WordPress must-use plugins or mu-plugins are a special type of plugin that is always on, which you cannot deactivate by conventional means. Let’s explore what they are, how to create one, and how they can help you develop and manage your site.
What are WordPress must-use plugins?
Mu-plugins are WordPress plugins that are activated by default. They are located in a subdirectory of wp-content
named mu-plugins
(wp-content/mu-plugins
). If you’re managing a multisite network, mu-plugins activate for all sites in the network.
Mu-plugins do not appear if you go to Plugins > Installed Plugins from your admin dashboard, but they appear in a special Must-Use tab once you have installed at least one mu-plugin. However, you cannot deactivate an mu-plugin from the dashboard because any plugin in wp-content/mu-plugins
is activated by default.
The only way to deactivate an mu-plugin is by manually deleting it from its directory.
WordPress must-use plugin features and drawbacks
An mu-plugin’s main feature is that it’s activated by default once installed (uploaded to the mu-plugins
folder). You also cannot uninstall mu-plugins from the Installed Plugins admin section. This prevents the accidental deletion of necessary features. Admins can only uninstall them by deleting their files.
Mu-plugins are loaded before regular plugins in alphabetical order. Any resources, API hooks, etc., added in an mu-plugin will be available to regular plugins later.
Finally, mu-plugins, have three significant drawbacks worth considering:
- Mu-plugins do not update automatically, do not appear in update notifications, and don’t show their update status on the Installed Plugins page. It’s entirely up to you to update them.
- Since they’re not activated like regular plugins, activation hooks don’t execute on mu-plugins. Activation hooks run installation code to set up rewrite rules, custom database tables, or set default option values. Plugins that require activation hooks may not work correctly if uploaded to the mu-plugins folder. Test your mu-plugins thoroughly before deploying them to a live site.
- WordPress doesn’t run PHP files in the subdirectories inside the mu-plugins directory or folder, only on the root. As a result, WordPress.org recommends you use a proxy PHP loader file inside the mu-plugins root:
<?php
// mu-plugins/load.php
require WPMU_PLUGIN_DIR.'/my-plugin/my-plugin.php';
?>
How to access WordPress must-use plugins?
The easiest way to access and see the installed mu-plugins is by going to Plugins > Installed Plugins > Must-Use (tab).
![screenshot showing the Must-Use tab in the Plugins section](https://wcanvas.com/wp-content/uploads/2023/10/mu-plugins-1-1024x623.jpg)
In the Must-Use tab, you’ll see the installed mu-plugins.
![screenshot showing a Must-Use plugin](https://wcanvas.com/wp-content/uploads/2023/10/mu-plugins-2-1024x623.jpg)
As you can see, you cannot activate, deactivate, or delete mu-plugins from the dashboard. The only way to deactivate an mu-plugin is to delete it from the mu-plugins
directory.
Remember that this tab doesn’t appear unless there’s at least one installed mu-plugin. You won’t see this tab if you’ve not installed any mu-plugins.
How to create and install a WordPress must-use plugin?
Creating an mu-plugin is similar to creating any other plugin, but the process differs slightly. Let’s work through the steps of creating an mu-plugin.
Note: Remember to back up your site before making any significant changes!
Step 1: Create the mu-plugins subdirectory in wp-content
Using a control panel provider by your web host, an FTP client, or your local environment, navigate to wp-content
and create a new directory. Name it mu-plugins
.
Step 2: Create the PHP file in mu-plugins’ root
Mu-plugins essentially consist of PHP files. To enable one, create a PHP file in the root of the mu-plugins
directory (remember that WordPress runs mu-plugins only from the mu-plugins
root). You either create your PHP file in the root or set up a proxy PHP loader file that points to your file’s location in a subdirectory.
In this case, we’ll simply create a PHP file in the root named test-mu-plugin.php
.
Step 3: Code your plugin
Now it’s time to code your plugin. Let’s create a very basic plugin that displays a text box.
<?php
/*
Plugin Name: Test Must-Use Plugin
Description: This is just a test.
Author: Andy
Author URI: https://wcanvas.com/
Plugin URI: https://wcanvas.com/
Version: 1.0
*/
add_action('wp_footer', 'displayTextBox');
function displayTextBox() {
echo '<p style="position: absolute;
font-size: 25px;
top: 180px;
right: 200px;
padding: 10px;
background-color: #000000;
color: #FFFFFF;">This is an mu-plugin test. Don\'t panic!</p>';
}
?>
It looks like this on the live site:
![screenshot showing a text box inserted by a Must-Use plugin](https://wcanvas.com/wp-content/uploads/2023/10/mu-plugins-3-1024x623.jpg)
This is a very rudimentary example, but it shows what you can do with mu-plugins!
Wrapping up
Mu-plugins are WordPress plugins activated by default, located in wp-content/mu-plugins
. These plugins are great for multisite networks, ensuring that the plugin executes on all of the network’s sites and that the sites’ admins cannot deactivate them. Mu-plugins generally work well for adding code that needs to run no matter what.
However, they have three significant drawbacks: you’re entirely responsible for updating them, they don’t support activation hooks, and they have to run from the mu-plugins
directory root.
If you know when and how to use them, mu-plugins can be very useful. For more WordPress insights and guides, visit our blog.
Related Articles
![](https://wcanvas.com/wp-content/uploads/2024/08/change-footer-BLOG-ARCHIVE.jpg.webp)
Development / 10 min read
Development / 10 min read
How to Change or Edit Your WordPress Footer
If you’re starting to dive deeper into your WordPress site, you may be wondering how to change or edit the contents of your footer. After all, it’s the part of…
Read More![The “Media” menu in WordPress’s admin dashboard](https://wcanvas.com/wp-content/uploads/2024/08/featured-image-size-in-wordpress-BLOG-ARCHIVE.jpg.webp)
Development / 8 min read
Development / 8 min read
How to Change the Size of Your Featured Image in WordPress
The size of the featured image in WordPress is an important factor in the look and feel of your posts, pages, and custom post types. As a result, you may…
Read More![A group of people using computers and smartphones with an "Upload" icon floating in the middle of the image](https://wcanvas.com/wp-content/uploads/2024/08/clean-up-uploads-folder-BLOG-ARCHIVE.jpg.webp)
Development / 7 min read
Development / 7 min read
How to Clean Up your WordPress Uploads Folder?
The WordPress Uploads folder is located on wp-content and contains all media files, such as images, videos, and documents, that you upload through the WordPress Media Library. Over time, it…
Read More![Various logos for social media applications on a smartphone screen](https://wcanvas.com/wp-content/uploads/2024/08/social-icons-color-BLOG-ARCHIVE.jpg.webp)
Development / 2 min read
Development / 2 min read
How to Change the Color of Social Media Icons in WordPress?
Looking for how to change the color of social media icons in WordPress? By default, social media icons in WordPress have unique colors. This can be great, but it can…
Read More![](https://wcanvas.com/wp-content/uploads/2024/07/wordpress-hide-page-title-BLOG-ARCHIVE.jpg.webp)
Development / 7 min read
Development / 7 min read
How to Hide the Page and Post Title in WordPress
Do you want to hide your post or page title in WordPress? Sometimes, it may be necessary to do it, especially if you want your home page or informational pages…
Read More