What is a must-use plugin (mu-plugin) in WordPress?
A must-use plugin (mu-plugin) is a PHP file placed in wp-content/mu-plugins. WordPress loads it automatically, before the normal plugins. You cannot deactivate it from the Plugins screen, and it has no activation or update steps.
<?php
/**
* Plugin Name: TC Must Use Demo
*/
add_filter( 'the_title', function ( $title ) {
return $title . ' *';
} );
Terminal output
$ wp plugin list –status=must-use –fields=name,status
name status
tc-mu must-use
$ curl -s http://example.com/hello-world/ | grep -o "<title>[^<]*"
<title>Hello world! – Demo Site
- Files in sub folders are not loaded automatically, you need a loader file.
- Use it for code that must always run: site wide rules, security checks or hosting features.
- The folder does not exist by default, you create it.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |