0

So this is how I have my structure setup to attempt to create a mu-plugin for my page.

Here is what I'm using: - Genesis Framework - Genesis FrameWork Child Theme

Please let me know if the mu-plugins directory should be there or moved inside the child theme, also to create just a simple mu plugin that echos 'Hello', where would I begin? Learning as I'm doing this.

Here is my current structure:
u

  • 1
    what are you trying to achieve with mu-plugins? mu-plugins and the genesis framework are unrelated, one is a parent theme, the other is a part of core WordPress. It doesn't make much sense to say you want create a plugin for a page, can you provide more context? Also, 3rd party theme support is offtopic on WPSE, you should contact Genesis support for Genesis support, or Genesis communities – Tom J Nowell Jan 20 at 19:54
1

So this is how I have my structure setup to attempt to create a mu-plugin for my page.

This statement does not make sense.

Here is what I'm using: - Genesis Framework - Genesis FrameWork Child Theme

mu-plugins have nothing to do with the Genesis framework. The Genesis framework is just a parent theme like any other WP theme. It was just built with the intention that you would build a child theme.

Please let me know if the mu-plugins directory should be there or moved inside the child theme,

You should never move the mu-plugins folder

also to create just a simple mu plugin that echos 'Hello', where would I begin? Learning as I'm doing this.

To say there's such a thing as an mu plugin is a bit of a stretch, but, this would be the equivalent:

<?php
echo "Hello";
exit;

The above code, saved in wp-content/mu-plugins/hello.php will output the word hello then exit, and it will do so on every page, every post, every RSS feed, every admin page, etc.

Now I wouldn't recommend doing this, as it means your site will be completely unusable until you delete the file. The mu-plugins folder is not a place to build your site, add features, or create content.

Basically, I don't think mu-plugins is what you think it is

What is mu-plugins?

This is a folder you can put PHP files in. WordPress will load those PHP files and run them before it runs the plugins and theme.

Important notes:

  • They always run, on every request, wether you want them or don't
  • They run earlier than plugins and themes
  • These aren't plugins, it's just the name of the folder
  • Plugin folders won't work, it's just single files ( you'd need to implement that yourself )
  • They can't be activated or deactivated, they're not plugins
  • The only way to get rid of them is to move them out of the mu-plugins folder

As the WP Admin screen says, it's just a folder of PHP files that automatically get executed:

enter image description here

They have more in common with dropins.

What Are mu-plugins Useful For?

A number of things, but:

  • server level stuff, e.g. I use it to load code that helps with Cron running with Cavalcade
  • Network wide hotfixes, e.g. if you visit a subdomain of my site that doesn't exist in my multisite, it'll redirect you
  • Network wide rules, e.g. I might want to add things that users cannot disable in their WP Admin interfaces , such as forcing an option on via a filter

mu-plugins aren't a very good place for functionality though, but they can be useful for low-level compatibility stuff and quick snippets.

What I Think You Actually Want

If you want to use PHP to put things on a page, or implement a page, there are lots of far better ways to do it:

  • A normal plugin in the plugins folder
  • Shortcodes! A great way to run PHP inside content, or just embed things
  • Page templates, a great way to completely change the code that powers a page
  • Theme templates, what you're working with might not be a page, not to worry, there'll be a template file for that, look up the template hierarchy diagram
  • Javascript!
  • OEmbeds, a great way to insert 3rd party content, such as youtube video players, or other things
  • Blocks! Take full advantage of the new block editor and build new blocks that add new things to your pages
  • The themes functions.php file

You have lots of options, but the mu-plugins is probably the very last place you should be thinking of

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.