Does wordpress allow me to add a php file to the root directory to execute custom scripts?

Does wordpress allow me to add a php file to the root directory to
execute custom scripts?

WordPress can’t prevent you from adding PHP files to the root directory, but there is no builtin functionality to load those files. You can load them yourself but if you are not careful they will load outside of WordPress context, which is a painful way to work.

What you want, almost certainly, is a plugin or a MU-Plugin. MU-Plugins work similar to what you are asking, if I understand you, but instead of placing your file in the site root you would place it in wp-content/mu-plugins/. It will be loaded automatically for all sites in the network and cannot be disabled except by deletion from the server.

Leave a Comment