Wordpressにて、自作テーマを使用するとページテンプレートを選択する項目が消える
wordpress 2.6.3にて、最初に設定できたはずの、ページテンプレートの項目がいつのまにかなくなっていた。
にあるとおり、default/archives.php, default/links.php を自作テーマディレクトリにコピーしたが現象変わらず。
ページ編集の wp-admin/edit-page-form.php では、
if ( 0 != count( get_page_templates() ) ) { function page_template_meta_box($post){
というところがあるので、get_page_templates()が0でなければいいということらしい。
で、 wp-admin/includes/theme.php を見てみると、
function get_page_templates() { $themes = get_themes(); $theme = get_current_theme(); $templates = $themes[$theme]['Template Files']; $page_templates = array (); if ( is_array( $templates ) ) { foreach ( $templates as $template ) { $template_data = implode( '', file( WP_CONTENT_DIR.$template )); preg_match( '|Template Name:(.*)$|mi', $template_data, $name ); preg_match( '|Description:(.*)$|mi', $template_data, $description ); ....
となっていて、$templatesがarray()でないといけないようだ。つまり、get_current_theme()が返す名前が問題あるのかもしれない。
テーマ名は自作テーマディレクトリのstyle.cssの先頭に、
/* Theme Name: テーマ名 */
と書いておく必要があるのだが、いつのまにかそれがなくなっていた(他の人がエディットすることもあるのでそれが原因だろう)。
これを復活させた後、管理画面のデザイン指定で、再度自作テーマを選択してみたところ、表示できた。