128 Responses

  1. Andrea_R
    Andrea_R Published |

    “it’s a bit of a hidden gem that I wish more folks knew about”

    Me too! +1000 for this. It’s a handy thing.

    Also! For those devs worried about clients disabling plugin on them – the use of this folder prevents that. ;)

    Reply
    1. Chunlin
      Chunlin Published |

      This is a really good way to tweak functions.php file, thanks for sharing!

      Reply
  2. Michael Martin
    Michael Martin Published |

    Great post Justin! Had no idea about the mu-plugins folder. I’d seen it before with WPMU installs but no idea the mu stood for something totally different. Very handy trick, especially for making sure clients can’t deactivate something important on their site, thanks!

    Reply
  3. Anthony
    Anthony Published |

    So cool, I haven’t ear about mu-plugin folder before reading this here, thanks !

    Reply
  4. Todd J. List
    Todd J. List Published |

    I like this idea. A LOT. I appreciate the tip about adding the must-use plugins folder, too. Thank you!

    Reply
  5. Bronson Quick
    Bronson Quick Published |

    Wow, here I was thinking that the mu-plugins folder only applied to multisite sites. That’s the best WordPress tip I’ve learnt in ages. Thanks for the post Justin!

    Reply
  6. Pippin Williamson
    Pippin Williamson Published |

    As with others, I had no idea that MU stood for must-use, instead of WPMU.

    Great ideas.

    Reply
  7. James
    James Published |

    Great tip. I can see how this would be very handy. I like the MU folder option too. Is this all that needs to be done for it to work or does some code need to be entered in the regular functions.php file to call the custom functions?

    Reply
  8. pcaWeb
    pcaWeb Published |

    Like others who have commented, I too had no idea about the “must use” plugin dir.

    It would be interesting to see the code you have in yours – ever considered putting it up for us to look at?

    Thanks for the post.

    Reply
  9. Markus
    Markus Published |

    great idea ;)

    Reply
  10. serge
    serge Published |

    I was still using the my-hacks file (I know it’s deprecated). I change now. Thanks for this tips.

    Reply
  11. paul
    paul Published |

    this is very cool indeed. thanks for the tips.
    so if it’s in the mu folder, there is no disable / delete link?
    what if I modify an existing plugin and don’t want the client to update it, can I put it there instead of using this :
    http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/

    Reply
  12. Gumz
    Gumz Published |

    First time to hear… Again, from you… :-)

    Reply
  13. Steve Taylor
    Steve Taylor Published |

    Ditto on the coolness of learning about mu-plugins!

    One thing is that my thinking about custom code kind of goes the other way round. I think, “If this code is portable, and I could use it on other sites, then [ideally!] I’ll make it into a plugin.” But stuff like custom post types and taxonomies – unless, of course, you’re creating a fully-fledged “management” plugin with a UI – is surely site-specific, and therefore is best as part of the theme’s functions.php.

    Of course, I’m thinking here of the bulk of my clients, who get me to create a completely custom theme for them. And of course, there’s nothing necessarily bad against creating plugins just for one site…

    Reply
  14. Randy
    Randy Published |

    I can’t believe I have been creating themes this long and had no idea this folder could be created. Thanks a million!

    Q: If you place a public plugin, like from the wp directory, will wp still notify when updates are needed? Or is it best to only use your own “custom” functions in the mu folder?

    Reply
    1. Simon
      Simon Published |

      Try here: http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/

      I have been chucking all my useful functions into a plugin file regularly for a couple years now.

      Good post!

      Reply
  15. Damon
    Damon Published |

    Great tip, and will definitely be using. I’m an old Mu user, and never even thought of this, but didn’t realize you could use on single install too. Kudos!!

    Reply
  16. Simon B
    Simon B Published |

    One important thing to note is that unlike the normal plugins folder, you cannot place must-use plugins in a subfolder. They have to be directly in the mu-plugins folder, or they will not work or show up in the plugins list.

    There are also a couple of handy constants available for use in your must-use plugins: WPMU_PLUGIN_DIR and WPMU_PLUGIN_URL.

    Reply
    1. Joshua Guffey
      Joshua Guffey Published |

      Thanks Simon! I forgot about the sub-folders. you may have just saved me a headache. -J

      Reply
  17. Adam W. Warner
    Adam W. Warner Published |

    A very timely post Justin. I was just at WordCamp Phoenix and attended a session about the creation and use of Custom Post Types. I asked if there were plugins that could be used to create and manage CPTs (and Custom Meta Boxes) and was told about one created by Brad Williams…but I was strongly encouraged to NOT use a plugin for CPTs.

    I’m very familiar with adding functions to my functions.php file, and making these into a portable plugin I can use seems like a good comprimise.

    Thanks for writing this up!

    ***feature creep*** – Do you think it would be a valid idea to take this further and create a GUI for people to either write or paste in their custom functions? Then output a list of all the functions to the admin and give them the option to turn them on and off?

    Reply
  18. Scott
    Scott Published |

    Woohoo, a hidden gem indeed!

    Thanks Justin.

    Reply
  19. Jamal Mohamed
    Jamal Mohamed Published |

    I already knew about drop-ins and I’ve used it for a couple of clients’ sites, but MU’s were “multi-user” to me until today ;)

    A good idea when you design a site for a half-tech-half-noob client.

    Reply
  20. Richard Vencu
    Richard Vencu Published |

    Hi, nice tip. What hook should we use here to call our functions? They are not anymore theme related so maybe there is no need to wait for ‘after_setup_theme’?

    Reply
  21. Richard Vencu
    Richard Vencu Published |

    Right. Maybe you can recommend some resources to understand how to choose the proper hook depending on the plugin function.

    I found out that I need to split what I put in the theme’s `function.php` file into several of those plugins for the sake of consistency and reusability, and they deal with some custom post types, some frontend editor, a points based rewarding system and some extended user management functions (additional metadata definition, etc).

    Reply
  22. Joshua Guffey
    Joshua Guffey Published |

    Thanks Justin. This is deceptively simple. I’ve been thinking for some time (as I’m sure others have) about how to do this in a ‘clean’ fashion. This is just perfect. And again, deceptively simple. Thanks for pointing it out!

    -Joshua Guffey

    Reply
  23. Renji Thomas
    Renji Thomas Published |

    Didn’t know that mu-plugins folder works with single site too. Thanks for the post Justin! :)

    Reply
  24. Another Cool Way to Keep WordPress Functions Organized and Portable! - VoodooPress
  25. Ryan
    Ryan Published |

    I ended up doing this after some comments from Otto quite a while back. He was suggesting creating a series of itty bitty plugins for each little thing that you need, that way it’s simply a matter of copying the individual plugins you need over to any other sites you may be working on. This has now resulted in me having dozens of tiny plugins running on my sites, but it’s pretty handy having all that code extracted out of a single chunk of code so that I can easily migrate them elsewhere when I need to. It doesn’t work so well on clients sites though as it’s a bit confusing having so many different (and usually poorly documented) plugins scattered around their install, so I still tend to use functions.php in that situation.

    Reply
  26. Stu
    Stu Published |

    I’ve been doing this for a while. I was always wondering if it was a good idea or not. Now I am much more confident in my approach! I think using the theme functions.php file for anything other than appearance related features is a very bad idea.

    Reply
  27. Jennifer
    Jennifer Published |

    Good article. I have a question. Do you know of a WP plug-in that will tell me how many hits a post gets on a blog?

    Reply
  28. WordPress Community links: Found by WordPress edition | WPCandy
  29. Linda moo
    Linda moo Published |

    hi

    please could you tell me could we modify complete wordpress, each and every themes will change to custom template and all files rename and it will looks custom developed script.

    can we do this ???? and is it possible.

    thanks

    Linda

    Reply
  30. Amy Hendrix
    Amy Hendrix Published |

    Like (apparently) a lot of folks, I knew mu-plugins from multisites, but had no idea that it could be used the same way for single installs. Adding it to the bag of tricks – thanks!

    Reply
  31. danon
    danon Published |

    You make a great point about the functions.php file. All too often some developers use that file in the theme to make major changes to the site and starts to get some sloppy nested loops or calls and slows down the entire site. This is a great way to handle some updating problems. Thanks

    Reply
  32. Marlon
    Marlon Published |

    Usefulness, thanks!

    Reply
  33. paul
    paul Published |

    I’m using it now to hide dashboard widgets and hide menus from the client, so they don’t break their site :)

    Reply
  34. Gary Taylor
    Gary Taylor Published |

    Brilliant. I’d already moved the functions in one site’s functions.php to a plugin file (the Family Tree web site which your custom taxonomies/post types tutorials have already helped with) because I use a different template for mobile visitors but the mu-plugins directory could come in very handy with clients who insist on having admin rights… I can just hide the plugins somewhere where they can’t delete them :->

    Reply
  35. Jean
    Jean Published |

    Nice stuff! Are there any advantages of using this approach versus building a custom framework and including it via the functions.php, similar to what we do with Hybrid Core?

    Reply
  36. kevin
    kevin Published |

    Very slick Justin, never even thought about using /mu-plugins – for non multi-site.
    Great article.

    Reply
  37. Mahmudur
    Mahmudur Published |

    Great post Justin. Thanks a lot.

    NB: I haven’t find any share button in this page to share this article.

    Reply
  38. Enrique Medina | Mexican Pottery

    Good information. Two years ago i try fix my own blog, but i do something wrong and die!

    Now leave that job to a programmer.

    Reply
  39. Robert
    Robert Published |

    Thanks for the excellent mu-plugin tip!

    I’ve been looking for a way to accomplish this very thing, and your insightful tip has provided me the solution that I was looking for.

    Reply
  40. Hitesh Bhasin
    Hitesh Bhasin Published |

    @ Justin – this is probably a wrong place to write this. But u are amazing. I have found ur presence across the internet on various places. Really respect your designing abilities. :)

    Reply
  41. russ weaver
    russ weaver Published |

    i have also come across some of these problems when editing themes iam going to use you method for custom plugins

    Reply
  42. mua sam vui
    mua sam vui Published |

    thanks ! i think with wordpress we jusst need a function file to do all of theme !

    Reply
  43. Steph Chasen
    Steph Chasen Published |

    That is awesome… Thanks for the tips… Very helpful indeed! It’s worth the read!

    Reply
  44. Eka Putra
    Eka Putra Published |

    Wow, it’s shocking.. its the first time I read about it, I did never know this WordPress hidden treasure are exists.

    Thanks for the great tips..

    Reply
  45. Sharma
    Sharma Published |

    Helpful tutorial. I want to create my own custom plugins for social bookmarking sidebar widget. And now I can do it with the help of this article. Will share my custom plugin soon. So, Thanks a lot.

    Reply
  46. Uncluttering the post editing screen in WordPress
  47. Ivan
    Ivan Published |

    Once I tried to do this, and failed. It seemed logical to me that custom post types and other non-theme options should go into file that has nothing to do with theme. So I created plugin and something went wrong. So, I believed that that is impossible to do. Thanks for this, I have just made what I wanted a year ago :)

    Reply
  48. Terry Sutton
    Terry Sutton Published |

    Fantastic post.

    Please keep up the great work you do. I’ve referred back to your posts dozens of times in the past few months.

    Terry

    Reply
  49. Tali
    Tali Published |

    Hey Justin,

    Thanks a lot. This was an awesome tutorial. Bookmark and Subscribe :)

    Reply
  50. Torben
    Torben Published |

    Never heard of the must use fuctionality before but I’m going to try it out.

    Reply
  51. Lee
    Lee Published |

    Fantastic. This has saved writing Child themes for those sites that only required a change or addition to the functions.php file.
    Thank you!

    Reply
  52. Dave
    Dave Published |

    Justin,

    Thanks for posting this. I didn’t know this existed. This is great for automating WordPress installs that use custom plugins for branded CMS purposes.

    Reply
  53. Land-of-web » Get started with writing plugin for wordpress (35 useful tutorials)
  54. Discoveries of the Week #7 | Bradley Durham Designs
  55. How To Build A Media Site On WordPress (Part 1) - Smashing Magazine
  56. David Cox
    David Cox Published |

    Great if you have control of the theme, but you would need to be careful for distributed themes.

    If the file called a function on load from a theme or a plugin, the developer did not code to see if it existed and escaped, and the theme or plugin was disabled would this be a fatal admin lockout?

    What I do at the moment with 2010 child themes is have a folder of smaller function files to be included, and have a function in functions.php to read all files in the folder onload.

    So I have, category-functions.php, meta-functions.php, facebook-functions.php, post-functions.php with a few theme specific calls in each, it is very easy to manage, I add one function in functions.php and it reads any file in the folder in.

    Thinking about it, it could be nice if WordPress looked for a ‘theme-mu’ folder and loaded any files into functions.php on run.

    This would mean functions could be split out into smaller targetted different functions files by developers.

    David

    Reply
  57. Creating a custom functions plugin for end users | UnHack WP
  58. Offering Support is not Always Easy - Tweaker Themes
  59. Pieter
    Pieter Published |

    Great tip. I’ve never heard about the mu-folder. From this day on, things will change! :) Thanks.

    Reply
  60. Should Custom Post Types live outside of themes? | themesforge.com - Wordpress Themes, Tutorials, News, Tips and More
  61. A Free wordpress newsletter » 20 Really Handy Tutorials to help you build WordPress Plugins
  62. SarDira
    SarDira Published |

    Never in 1000 years I would have thought that mu stands for MustUse!!

    Thanks so much, you’ve changed my life forever!

    Reply
  63. How to Incorporate Humans.txt into Your WordPress Site | Bitmag
  64. How to Incorporate Humans.txt into Your WordPress Site | WebDesign Terminal
  65. Bookmarks for January 29th through January 30th | dekay.org
  66. McBart
    McBart Published |

    Very useful tip. This makes adding code even more confinement.

    You can just upload the custom code plugin the normal way via wordpress plugin upload function, test it and when all is well, move it to the mu-plugin folder.

    Thanks for this very well done tip!

    Reply
  67. Chris
    Chris Published |

    Your info about the mu-plugins folder is the useful tip on WP useage I have seen in ages. Thanks mate.

    Reply
  68. Pete
    Pete Published |

    Nice… I’ll use this

    Reply
  69. How to Incorporate Humans.txt into Your WordPress Site | Blog
  70. Daniel McClure
    Daniel McClure Published |

    I’ve seen the mu-plugins folder before but didn’t realise that it stood for must use! Thanks for sharing this information, will definitely be putting it to use for my functionality plugins in future.

    Reply
  71. Brandon
    Brandon Published |

    Man this rocks, thanks Justin!
    It sure makes migrating function from theme to theme without adding too much to each functions file.

    Reply
  72. 16 Helpful Tutorials for Creating WordPress Plugins
  73. Post format plural strings
    Post format plural strings at |
  74. Custom URLs for post formats
    Custom URLs for post formats at |
  75. rohit
    rohit Published |

    i saw this code but didn’t knew what it was… thanks !

    Reply
  76. Mark from Germany
    Mark from Germany Published |

    Great. It works. And it is extremy useful.
    “mu-plugins” will be my favorite folder! ;-)

    Reply
  77. Stephanie
    Stephanie Published |

    Hi Justin,

    Great advice on making custom modifications! I recently downloaded your feature a page widget and got into the read me file to make the “read more…” mod and haven’t been able to succeed. I’m not sure if it’s due to the theme I’m using, Suffusion. I initially updated the functions.php with no luck and then created the mu-plugins folder per this post with the my-custom-functions.php from the code in the read me doc of the plugin and still no luck. Just wondering if you could point me in the right direction :o)

    Thanks!
    Stephanie

    Reply
  78. How To Build A Media Site On WordPress (Part 1) | WordPress Planet
  79. Must Use Plugins VS functions.php | World WordPress
  80. Den
    Den Published |

    Thank you! Been using WP for years and Thesis “custom-function.php” but moving away from that to our own in-house framework. This is perfect!

    Reply
  81. 30 Useful Tutorials to Create WordPress Plugin | Doublemesh
  82. Create Functions file plugin for WordPress
  83. Ray
    Ray Published |

    I have tried both methods, both report the same errors

    “The plugin generated 674 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin”

    any ideas, what have I don’t wrong?

    Reply
    1. Ray
      Ray Published |

      oops, It’s OK error in copy & paste, doh!

      Reply
  84. How to change your author archive link
    How to change your author archive link at |
  85. Simplifying 'My Sites' toolbar menu in WordPress multisite / WP Journo: WordPress & Journalism
  86. Top 160 Tutoriais WordPress – incluindo Basico, Desenvolvimento e Plugins – Site para Empresas – Blog sobre Internet e Criação de Site
  87. Globally Edit Dashboard CSS in WordPress Multisite - Shane Gowland
  88. Sinan Atici
    Sinan Atici Published |

    Actually I was looking for how to create custom post types. And now I got what is mu-plugins means. Its better using a plugin when creating custom post types than functions.php. I decided to make a plugin (mu-plugins). I asked what if I want to use an another theme? Better way is letting to hold the daha custom post type plugin…

    Reply
  89. Separate theme display and functionality with a build-your-own custom functionality plugin | WordPress Snippets
  90. Kassiah
    Kassiah Published |

    Thanks so much for this awesome tutorial. I can’t wait to try it out.

    Reply
  91. Globally Edit Dashboard CSS in WordPress Multisite - The Web Atom
  92. Where to put your custom WordPress functions | brettrawlins.com
  93. Ashish Chandra
    Ashish Chandra Published |

    Mind blowing article, Justin. You are the man. I have never heard about mu-plugins folder before. A must-see article for everyone having a blog.

    Reply
  94. Creating a custom function plugin - Arctic WebSolutions
  95. Saku Mättö
    Saku Mättö Published |

    Hi Justin,

    I’ve been using this tip of yours very successfully, thanks a lot. Now, however I ran into a snag.

    I want to replace the Genesis 404 with a Finnish language 404 and other custom stuff. I placed my code into the mu subdir as normally, but with the genesis(); call at the end I get an error and with that removed I get the custom 404 AND the Genesis 404.

    Also, I’m not sure should I remove

    remove_action( 'genesis_loop', 'genesis_do_loop' );

    OR

    remove_action( 'genesis_loop', 'genesis_404' );

    Do you have a quick solution I might try?

    Thanks,

    Saku

    Reply
  96. Wordpress Top 160 Tutoriais | Blog do Dinheiro Brazil
  97. How To Build A Media Site On WordPress (Part 1) | Smashing WordPress
  98. Ed Watson
    Ed Watson Published |

    Works like a charm. Thanks!!!!!!!

    Reply
  99. How to Create a Custom Functions Plugin for WordPress - BytesWire
  100. Things learned while building a hosted Web Forum service with WordPress Multisite - The Web Atom
  101. How to hide the main site in the "My Sites" admin menu (Multisite) | BP-Tricks
  102. Experimenting with HTML5 image markup in WordPress - Synapticism
  103. Experimenting with HTML5 image markup and shortcodes in WordPress - Synapticism
  104. 30 Useful Tutorials to Create WordPress Plugin
  105. รวมสุดยอดสอนแต่ง WordPress ขั้นเทพ | HopeApps.com
  106. Steve
    Steve Published |

    Thanks very much for posting this, its a hidden gem. I am very glad I stumbled upon it.

    Reply
  107. Functions File Explained | COMP 1920
  108. The WordPress mu-plugins folder | rebdev
  109. jenny
    jenny Published |

    I never even knew this was possible, and learning it just saved my hide, 3 years after you posted it. Thanks!

    Reply
  110. James
    James Published |

    Just adding my own 2¢ of thanks for your post, Justin.

    2am bacon saver.

    There’s now a plugin on WP called “my-custom-functions”

    which allows for the functionality you same described…

    … ‘cept by my reading believe the author’s put safeguards in re self-harm of getting it wrong.

    Thanks again Justin :)

    Reply
  111. Lord Gareth Lloyd
    Lord Gareth Lloyd Published |

    Thank you for the plugin idea I had no idea of this option! So basically I create using the step above and simply add the function code as if it were being pasted directly into functions.php if I have understood you correctly?

    Excellent work and thanks for sharing. This has helped me to make many a plugins and left me free for future theme updates.

    It has made it a breeze to incorporate on my other sites and use the plugins for client sites also.

    Someone always asks me wherever I put my name so I shall answer the question now ” as my title suggests I am of a genuine Lordship title”.

    Thanks once again you have saved me hours!

    Reply

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.

css.php