wp_get_theme()函数

wp_get_theme()函数主要作用是用来获得WordPress主题的相关信息。
语法

<?php wp_get_theme($stylesheet, $theme_root) ?>

参数

参数1:内容为查询的主题名,可选。默认值:null

参数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()函数详细参数:

Name:主题名
ThemeURI:主题 URL
Description:主题描述
Author:作者名
AuthorURI:作者 URL
Version:主题版本号
Template:父主题的文件夹名称,子主题中使用
Status:主题状态,如果发布的话
Tags:标签
TextDomain:主题中用于翻译目的的文本域
DomainPath:主题翻译文件路径
当然啦,wp_get_theme()函数还可以指定主题名来获取指定主题的其它信息,如下:

<?php
$theme = wp_get_theme( ‘Viti’ );
if ( $theme->exists() )
echo $theme;
?>

  • 3554稳定运行(天)
  • 1会员总数(位)
  • 28195资源总数(个)
  • 0 本周更新(个)
  • 0今日发布(个)

目前已经有 1 位会员加入