Autoload Must Use Plugins in Sub Folders in WordPress

In WordPress, there is a special folder in wp-content: mu-plugins which stands for Must Use Plugins. WordPress automatically loads all PHP files in this folder. This is a very cool features if you want to always turn on some plugins such as debugging plugins, SEO plugins or functionality plugin for your blog. The problem is WordPress doesn’t load files in sub folders, that means when you put a plugin as a folder into mu-plugins, it won’t be loaded.

To solve this problem, I use a simple trick: create a simple PHP file in mu-plugins and include all plugins’ main files.

For more details, let’s look at my mu-plugins:

MU Plugins Loader

As you see, there’s a PHP file load.php, and this file contains only these lines:

<?php
include 'inspector/inspector.php';
include 'monkeyman-rewrite-analyzer/rewrite-analyzer.php';
include 'wordpress-reset/wordpress-reset.php';
include 'wordpress-importer/wordpress-importer.php';

Now, when I go to Plugins menu, I see the PHP file is loaded as well as needed plugins:

Loaded MU Plugins

Now I have a bunch of debugging plugins always activated. This saves me a lot of time when developing themes, plugins and fixing bugs. Putting those plugins in mu-plugins folder also is a good way to organize plugins files. For more information about Must Use Plugins, please read more at the Codex.

4 thoughts on “Autoload Must Use Plugins in Sub Folders in WordPress

  1. I have some email marketing plugins that I need to update. Going to try this out to keep certain plugins running on my test install.

  2. Hi Rilwis,

    Great tutorial, i have a self hosted wp-blog other than my blogger. Though i am a newbie blogger, i am having fun learning new things from experienced ones such as yourself!

    Thanks for the help,

    Piyush

Comments are closed.

Newsletter

Subscribe to our newsletter to receive news and tutorials about WordPress and web development.

Memory - An elegant, clean and powerful WordPress blog theme! Learn more →