wp_get_theme()函數(shù)主要作用是用來獲得WordPress主題的相關(guān)信息。
語法
<?php wp_get_theme($stylesheet, $theme_root) ?>
參數(shù)
參數(shù)1:內(nèi)容為查詢的主題名,可選。默認值:null
參數(shù)2:主題根要查看的絕對路徑。可選。如果沒有指定,get_raw_theme_root()用于計算主題根為樣式表提供(或當前主題)。默認值:null
實例
<?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ù)詳細參數(shù):
當然啦,wp_get_theme()函數(shù)還可以指定主題名來獲取指定主題的其它信息,如下:
<?php
$theme = wp_get_theme( 'Viti' );
if ( $theme->exists() )
echo $theme;
?>