WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just moved a site (by exporting & importing all posts & pages, and copying theme files over), and on the new site the various page and post templates are unavailable for selection on post and page edit screens.

The files did have Windows line endings, which I fixed, but that did not eliminate the problem. Any other things to try?

share|improve this question
Did you reactivate all Plugins after you copied them over? Also, what is providing the Post template functionality: your Theme, or a Plugin? – Chip Bennett Jul 7 '11 at 22:08
That functionality is provided by the Category Templates plugin. I've tried deactivating other plugins, de/re-activating that plugin, de/re-activating the theme, etc., but no luck. – tnorthcutt Jul 8 '11 at 14:26
And (dumb question) you've verified that all template files copied over properly? – Chip Bennett Jul 8 '11 at 14:33
Yeah, they're all there, visible in the WP theme editor, etc. – tnorthcutt Jul 8 '11 at 14:36
Crazy thought: switch Themes, and then switch back? – Chip Bennett Jul 8 '11 at 14:39
up vote 4 down vote accepted

Sounds like it could be an issue with the database and serialization of the plugin options. I've had problems before with plugin settings etc when moving a site using the xml export. The category templates plugin writes a lot of options to the db and they could be corrupted.

As a test try creating a php file and putting it in the themes root directory. Add the basic template header:

* Template Name: Template Test

See if it's available to choose from.

If you still have access to the old site / server try doing an mysql dump of the database then create a new blank database and import the dump file.

Also you didn't mention the server / hosting environment of the new and old locations. That info might help debug the issue.

Also wanted to mention that the Category Templates plugin has issues which may or may not be the cause of the problem.

The plugin uses serialize and unserialize in its update_option() and get_option() calls. WordPress already does the serialization for those functions see: http://andrewnacin.com/2010/04/18/wordpress-serializing-data/

If you look at the first few lines of the plugin:

function cat_temp_menus() {
    add_submenu_page('themes.php','Category Templates', 'Category Templates', 8, basename(__FILE__), 'cat_temp_options_page');
    if (function_exists('add_meta_box')) {
        add_meta_box('cat_template_select','Post Template','cat_temp_meta','post','side','low');

The add_submenu_page function is using user roles (the 8) which was deprecated in version 2.0.

The syntax should be: <?php add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ) ?>

It's also using basename(__FILE__) as the admin menu page slug which is a minor security issue.

Notes For $menu_slug please don't use FILE it makes for an ugly URL, and is a minor security nuance. (See Codex)

That line in the code should be:

function cat_temp_menus() {
    add_submenu_page('themes.php','Category Templates', 'Category Templates', 'activate_plugins', 'themes.php?page=cat_temp_options_page', 'cat_temp_options_page');
    if (function_exists('add_meta_box')) {
        add_meta_box('cat_template_select','Post Template','cat_temp_meta','post','side','low');

So my answer is that the problem is most likely the plugin and my suggestion would be to either rewrite it or find another one.


I decided to rewrite the plugin fixing all the issues since the author isn't really supporting it anymore. For now it's on GitHub: https://github.com/c3mdigital/Category-Templates

share|improve this answer
Wow, you're really taking care +1 – hakre Jul 14 '11 at 16:26
Chris, thanks for the spectacularly detailed answer. I'll be trying your rewritten plugin a little later, hopefully tonight. The new hosting environment is actually page.ly, which of course limits what I can do as far as DB access. – tnorthcutt Jul 14 '11 at 22:46
@tnorthcutt let me know how it works. I'm adding the plugin to wp.org today. – Chris_O Jul 15 '11 at 18:23
Worked perfectly. Thanks for checking back. – tnorthcutt Jul 15 '11 at 20:59

You mentioned Windows line-endings. Did you move from a Windows host to a Linux host? Since Windows doesn't care about capitalization and Linux does, is it possible that capitalization of the filenames is messing you up now? Like the template names are capitalized in the settings (and database) but the files are lowercased, and they're not the same file to Linux so they can't be found?

share|improve this answer

I'd try this... delete it then reupload it.

share|improve this answer

Puzzle. Check permissions on the template files, and be sure wp-content is 755. The files should be Unicode no-BOM on a Linux box. Get rid of any whitespace above the the template file headers. And see if page templates show up in twentyten, to rule out admin.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.