wp_get_theme()函數(shù)主要作用是用來(lái)獲得WordPress主題的相關(guān)信息。
語(yǔ)法
<?php wp_get_theme($stylesheet, $theme_root) ?>
參數(shù)
參數(shù)1:內(nèi)容為查詢的主題名,可選。默認(rèn)值:null
參數(shù)2:主題根要查看的絕對(duì)路徑??蛇x。如果沒(méi)有指定,get_raw_theme_root()用于計(jì)算主題根為樣式表提供(或當(dāng)前主題)。默認(rèn)值:null
實(shí)例
<?php
$theme = wp_get_theme();
echo $theme->get( 'Name' ); //主題名
echo $theme->get( ThemeURI' ); //主題 URL
echo $theme->get( Description' ); //主題描述
echo $theme->get( Author' ); //作者名
?>
wp_get_theme()函數(shù)詳細(xì)參數(shù):
當(dāng)然啦,wp_get_theme()函數(shù)還可以指定主題名來(lái)獲取指定主題的其它信息,如下:
<?php
$theme = wp_get_theme( 'Viti' );
if ( $theme->exists() )
echo $theme;
?>