A “Must-Use” plugin is like an ordinary WordPress plugin – it can contain code that shapes what WordPress does – but it has a few advantages such as:
- runs earlier in the WordPress loop
- cannot be deactivated
- applies to all sites in a multi-site WordPress install
Being ran earlier in the loop is important when you need to ensure your code runs before another plugin.
To create a “Must-Use” plugin you will need access to the files and folders on your server – this may be through your web host’s “cPanel” account or FTP.
- Browse to the wp-content directory
- Create a new directory called mu-plugins – so you have /wp-content/mu-plugins
- Open the mu-plugins directory
- Create a new text file and give it a name followed by .php – for example itsg_mu_plugin.php
- This leaves you with /wp-content/mu-plugins/itsg_mu_plugin.php
- Edit the file and add the following to the top of the file (you can change the details to suit)
-
<?php /* Plugin Name: itsupportguides.com must-use plugins Description: code that always runs Version: 1.0.0 Author: IT Support Guides Author URI: itsupportguides.com */
- Save the changes – you now have a “Must Use” plugin!
- To use – add your custom functions below the */ line