WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User talk:Dcole07

This article is a ROUGH DRAFT. The author is still working on this document, so please do not edit this without the author's permission. The content within this article may not yet be verified or valid. This information is subject to change.

The following is an unofficial standard for hooks within WordPress Themes. This standard is designed to improve the quality of themes and relation their relationship with WordPress plugins. Currently this is a work in progress, please take it with a grain of salt. Use the hooks that make sense to have.

Why You Should Use This Standard

  • It makes it easier for plugin authors to insert features a wide variety of themes.
  • Users will not need to dig through your code and insert function calls.
  • Makes tutorials universal
  • Without this solution, more themes will develop their own theme options, when a common group plugins would work better.

Basic Template

The following code should be common within all page templates. The code below uses PHP functions, not the actual hook code.

<?php theme_doctype(); // create filter with same name ?>
<html>
  <head>
    <?php theme_head(); // create action with same name ?>
    <?php wp_head(); // nothing more needs to be done ?>
  </head>
  <body>
    <?php theme_before_container(); // create action with same name ?>
    <div id='container'>
      <?php theme_before_header(); // create action with same name ?>
      <div id='header'>
        <?php theme_header(); // create action with same name ?>
      </div>
      <?php theme_after_header(); // create action with same name ?>
      <?php theme_before_content(); // create action with same name ?>
      <div id='content'>
        <?php theme_content(); // create action with same name ?>
      </div>
      <?php theme_after_content(); // create action with same name ?>
      <?php get_aside(); // Your sidebars ?>
      <?php theme_before_footer(); // create action with same name ?>
      <div id='footer'>
        <?php theme_footer(); // create action with same name ?>
        <?php wp_footer(); // nothing more needs to be done ?>
      </div>
      <?php theme_after_footer(); // create action with same name ?>
    </div>
    <?php theme_after_container(); // create action with same name ?>
  </body>
</html>

The asides(); fetches the function that attaches any sidebars. The other functions attach WordPress hooks, which plugins can then use.

List of Standard Hooks for Themes

  • theme_doctype -- filter
  • theme_head -- action
  • theme_before_header -- action
  • theme_header -- action
  • theme_after_header -- action
  • theme_before_content -- action
  • theme_content -- action
  • theme_after_content -- action
  • theme_before_footer -- action
  • theme_footer -- action
  • theme_after_footer -- action
  • theme_before_entry -- action
  • theme_after_entry -- action
  • theme_before_comments -- action
  • theme_after_comments -- action

Themes That Use This Standard

  • Parallel Theme

Please list your theme here if it uses the standard.