Title: テーマファイルのバージョンの取得について
Last modified: 2010年12月8日

---

# テーマファイルのバージョンの取得について

 *  [nobita](https://ja.wordpress.org/support/users/nobita/)
 * (@nobita)
 * [15年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%83%86%e3%83%bc%e3%83%9e%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%81%ae%e5%8f%96%e5%be%97%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6/)
 * こんにちは、
 * テーマファイルのファイルヘッダを取得したいのですが、うまくいきません。
    やり方
   の間違いや、正しい方法を教えていただきたくお願いします。
 * functions.php
 *     ```
       $theme_name = get_current_theme();
       $theme_data = get_theme_data($theme_name);
   
       echo "v-".$theme_data['Version'];
       echo '<pre>';
       var_dump($theme_data);
       echo '</pre>';
   
       結果が以下の様になり、style.css　の　ヘッダ情報が取得できません。
   
       array(11) {
         ["Name"]=>
         string(0) ""
         ["URI"]=>
         string(0) ""
         ["Description"]=>
         string(0) ""
         ["Author"]=>
         string(6) "匿名"
         ["AuthorURI"]=>
         string(0) ""
         ["Version"]=>
         string(0) ""
         ["Template"]=>
         string(0) ""
         ["Status"]=>
         string(7) "publish"
         ["Tags"]=>
         array(0) {
         }
         ["Title"]=>
         string(0) ""
         ["AuthorName"]=>
         string(6) "匿名"
       }
       ```
   

2件の返信を表示中 - 1 - 2件目 (全2件中)

 *  [kz](https://ja.wordpress.org/support/users/kz/)
 * (@kz)
 * [15年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%83%86%e3%83%bc%e3%83%9e%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%81%ae%e5%8f%96%e5%be%97%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6/#post-134048)
 *     ```
       require_once ( ABSPATH . 'wp-admin/includes/theme.php' );
       $theme = current_theme_info();
       echo 'v-' . $theme->version;
       echo '<pre>';
       var_dump( $theme );
       echo '</pre>';
       ```
   
 * とかでどうでしょう。
 *  トピック投稿者 [nobita](https://ja.wordpress.org/support/users/nobita/)
 * (@nobita)
 * [15年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%83%86%e3%83%bc%e3%83%9e%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%81%ae%e5%8f%96%e5%be%97%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6/#post-134059)
 * kzさん　ありがとうございます。
 * とても参考になりました。
 *     ```
       function my_current_theme_info() {
       	$themes = get_themes();
       	$current_theme = get_current_theme();
       	if ( ! isset( $themes[$current_theme] ) ) {
       		delete_option( 'current_theme' );
       		$current_theme = get_current_theme();
       	}
       	$ct->name = $current_theme;
       	$ct->title = $themes[$current_theme]['Title'];
       	$ct->version = $themes[$current_theme]['Version'];
       	$ct->parent_theme = $themes[$current_theme]['Parent Theme'];
       	$ct->template_dir = $themes[$current_theme]['Template Dir'];
       	$ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
       	$ct->template = $themes[$current_theme]['Template'];
       	$ct->stylesheet = $themes[$current_theme]['Stylesheet'];
       	$ct->screenshot = $themes[$current_theme]['Screenshot'];
       	$ct->description = $themes[$current_theme]['Description'];
       	$ct->author = $themes[$current_theme]['Author'];
       	$ct->tags = $themes[$current_theme]['Tags'];
       	$ct->theme_root = $themes[$current_theme]['Theme Root'];
       	$ct->theme_root_uri = $themes[$current_theme]['Theme Root URI'];
       	return $ct;
       }
   
       $theme = my_current_theme_info();
       echo 'v-' . $theme->version;
       echo '<pre>';
       var_dump( $theme );
       echo '</pre>';
       ```
   
 * で取得できました。

2件の返信を表示中 - 1 - 2件目 (全2件中)

 トピック「テーマファイルのバージョンの取得について」には新たに返信することはでき
ません。

 * フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2件の返信
 * 2人の参加者
 * 最後の返信者: [nobita](https://ja.wordpress.org/support/users/nobita/)
 * 最後の活動: [15年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%83%86%e3%83%bc%e3%83%9e%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%81%ae%e5%8f%96%e5%be%97%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6/#post-134059)
 * 状態: 未解決

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
