Hacking WordPress

跳转至: 导航搜索
onlyincludetabletrtdspan style=float:left; margin:4px/spanThis 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.


div class=template-description style=padding: 15px; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

See Codex:Maintenance.


  1. note -- (optional) text at the end of above sentence.
  2. ver -- (optional) WordPress version. e.g. 'WordPress 2.3'
    • Default: 'an older version of WordPress'


pre检查到模板循环:模板:Oldversion/pre pre检查到模板循环:模板:Oldversion./pre



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.