Back in 2004, in WordPress 1.2 plugin was introduced in this platform. Since then, plugin is the most important part of WordPress system. WordPress has given us enough flexibility to extend the functionality by plugin.
We all are already used to with plugin. Whenever we need a plugin we can keep deactivated that plugin, or activate it when we need. But, sometimes we need something important and we always want to keep that functionality active in our WordPress site. Here comes mu-plugins. “mu-plugins” means Must Use Plugins – the plugins is always activated and there is no way to deactivate that plugin.
The code we use in a mu-plugin, we can use the same code in our theme’s functions.php file or in an existing plugin or even as a stand-alone plugin. So, why mu-plugins? Well, when we use the code in functions.php file, we will lose the code when the theme will be updated. Same for plugins. When we update something – plugins or themes, all the manual changes will be lost. Yes, we can use a child theme to avoid this, but most of us changes theme in certain interval but we still want that functionality. Using the code snippet as a stand alone plugin is a good idea, but not the best, as accidentally we may deactivate the plugin and forget about it.
So remember, mu-plugin is something that we always want in our site and never wants to deactivate.
How can we make a mu-plugin then? What we have to do is to create a folder called “mu-plugins” inside of wp-content folder, where the plugins, themes and uploads folder are by default. So, folder structure will be /wp-content/mu-plugins.
Now, we will create a file in our desktop, called anything.php. Well, anything – yes, I mean it. You can can name it anything you want, just make sure the file extension is .php. So, it could be plugins.php or item.php or even blablabla.php
Now, place your code in that file, of course start with php tag (
So, start using mu-plugins from right now!
1. If you want to deactivate the must use plugin, you have to delete the file
2. The plugins are always activated
3. These plugins are loaded before the normal plugins