Template files missing after moving site

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:

<?php
/*
* 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.

Update:

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

Leave a Comment