Tag Archives: themes

Themes and WordPress 3.0 some important changes

During the development of WordPress 3.0 we have made a number of changes under the hood which will be of interest to the developers and users of themes.  Some of these changes are about making themes easier to develop and some of them are about making it easier to support the override of parts of themes.

1) get_template_part – [13146], #12371

The first change which should make it easier for extensible flexible theme development is the introduction of get_template_part() which has been introduced as a generic way of modularising themes a step beyond the basic footer/body/header files.  This new function makes it very easy for a theme to reuse blocks of code implementing theme areas such as the WordPress loop in a way which makes it easy for a child theme to override the implementation in a context sensitive way.

This function is really easy to use – You create a file within your theme containing the code you want to re-use and then you pull it in as follows:

get_template_part( 'loop', 'author' ); // Pull in the loop for the author archives

This will look for the files loop-author.php and loop.php searching first in the current themes folder before looking in the parent themes folder (if one if defined).  The new TwentyTen theme in WordPress 3.0 uses this for every call to it’s loop.php to make it easy to override in a single instance from a child theme.

2) Deprecating overly minimal themes [14365], #12425

The next change is to deprecate the support for overly minimal themes.  Prior to WordPress 3.0 any theme which was using the relevant template tag but missing any of the following template files – header.php, footer.php, sidebar.php, comments.php, comments-popup.php – would effectively behave as if it has a parent theme defined as ‘default’ using the relevant files from the old default theme.

Now that we are moving to a new default theme we didn’t want to have to support this very old behaviour indefinitely or make it such that the files from the TwentyTen theme were used as they have a different visual layout and would like change peoples existing sites.

Going forward a WordPress theme using the relevant template tags is expected to contain all these files itself, or have them provided by a parent theme, and the theme compatibility files included in WordPress 3.0 will be removed in a future version.

If you are using a theme which is affected by this change then you just need to make sure that you have the default theme installed – it will not be in new installs but will be preserved on upgrades. Then add the following to the comment at the top of the style.css of your theme to make it such that the default theme is used as its parent theme:

Template: default

More information on the process of indicating a parent theme in a child themes style.css is available in the codex.

WordPress weekly digest 12th November to 18th November 2007

It has been another busy week for WordPress 2.4, the changes this week have included:

  • Output WP_Error message when adding categories via AJAX (#5342).
  • WXR Importer fix to ensure that tags are imported correctly (#5330).
  • A change to the capability checks used by “submit-for-review” to ensure the same capability is check in all cases (#5329).
  • Caching of the current theme in options (#5346).
  • Refactor of the WXR exporter to allow for unit-testing (#5347).
  • Improvements to the memory usage of the WXR importer (#5357).
  • Changes to ensure that when the page set as the homepage is deleted we revert to a blog view on the homepage (#5361).
  • Ensure that we offer https access to atom in the RSD if it is available (#5298).

For even more information on some of the other little changes that went in this week you can read the whole weekly trac timeline.