WordPress.org

Codex

Hacking WordPress

This article may be outdated and contain information pertaining to an older version of WordPress. Please take caution when following the procedure, as many things may have changed.

In very early versions of WordPress, the only way to modify the behavior of WordPress was through a "hack", i.e. by modifying the core files of WordPress. However, since version 1.5, WordPress has offered both plugin and theme capabilities as mechanisms to modify nearly everything that WordPress does, from looks to functionality, so hacks are seldom necessary any more, and certainly not recommended.

Since at least version 2.8, my-hacks.php file is not supported any longer.

Hacks are not officially supported by WordPress. Use at your own risk.

Using WordPress Hacks

Although hacks are not recommended, and since version 1.5 of WordPress, seldom necessary, for completeness, this article still documents the my-hacks.php file, which you can enable and use for "hacks". Basically, you can put PHP functions and variable definitions into this file (which goes into your root WordPress installation directory), and if you activate it, it will be loaded just before plugins when WordPress starts up.

To activate my-hacks.php:

  • In the Administration Panel, choose Options > Miscellaneous.
  • At the bottom of the page, click the check box for Use legacy my-hacks.php file support to put a check in it.
  • Click Update to save the changed option.