Sponsored Link

現在利用しているテーマファイル名を調べる。

8月 26th, 2009 by admin Leave a reply »

カレントテーマファイルの情報(style.css)のコメント欄に記載しているものを、取得したい。
と思いましたが、そのような日本語情報は、少なかったので、メモに残しておきます。

現在使用しているテーマの名前は、以下のようにして求められるようです。

$name = get_current_theme();

詳細は、includes/theme.php より、

/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @return unknown
 */
function current_theme_info() {
	$themes = get_themes();
	$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'];
	return $ct;
}

また、以下の関数でも取得できるようです。

<?php
    $theme_data = get_theme_data(ABSPATH . 'wp-content/themes/default/style.css');
    echo $theme_data['Title'];
    echo $theme_data['Author'];
?>
Advertisement

Leave a Reply