WordPress Theme Admin Page Tip

In WordPress 2.7.1 (and probably previous versions), the admin page that allows for theme activation has some behavior that you might find sub-optimal in certain conditions.

Today I was setting up a site and wholesale replaced the default ‘wp-content/themes’ directory with a ‘wp-content/themes’ directory checked out of our SVN. This removed the default theme (Kubrick) and left only the theme I was working on for the site.

For some reason, the theme admin page did not show any themes – it took me about 20 minutes to trace the code to figure out what was going on.

The wp-admin/themes.php file has code at line 139 that checks to see if more than one theme is present:

if ( 1 < $theme_total ) {

If more than 1 theme is found, then the grid of themes is shown so that you can choose between them. However, in my situation I had deleted all other themes leaving just 1 theme but had not yet activated that theme. With this edge case, no theme is active, and there is no way to select the 1 theme that is in the 'wp-content/themes' directory.

A workaround is to change that code to:

if ( 1 <= $theme_total ) {

or to upload another theme. Then you can select the theme you need, and you're good to go.

I've opened a bug for this here, so I'm sure this will be fixed in the near future. Hopefully this information will be helpful to someone else who runs into this situation in the interim.

UPDATE: I did search Trac, but apparently not well enough. Original bug here for those wanting to review.