WordPress: Function Reference/get theme data:修订间差异
来自站长百科
无编辑摘要 |
无编辑摘要 |
||
第1行: | 第1行: | ||
== 描述== | == 描述== | ||
返回主题文件的一组信息。 | 返回主题文件的一组信息。 | ||
== 用法 == | == 用法 == | ||
%%% <?php $theme_data = get_theme_data($theme_filename); ?> %%% | %%% <?php $theme_data = get_theme_data($theme_filename); ?> %%% | ||
== 例子 == | == 例子 == | ||
=== 用法 === | === 用法 === | ||
从默认主题style.css中得到信息,并且如果存在的话,显示名称和链接进的作者,以及相关的URIs。 | 从默认主题style.css中得到信息,并且如果存在的话,显示名称和链接进的作者,以及相关的URIs。 | ||
第34行: | 第20行: | ||
?> | ?> | ||
</pre> | </pre> | ||
== 参数 == | == 参数 == | ||
{{Parameter|$theme_filename|string|主题的 <tt>style.css</tt>路径和文件名。}} | {{Parameter|$theme_filename|string|主题的 <tt>style.css</tt>路径和文件名。}} | ||
==返回值 == | ==返回值 == | ||
函数返回一个数组,包含下面键入的信息。 | 函数返回一个数组,包含下面键入的信息。 | ||
; 'Name' : (''string'')主题名。 | ; 'Name' : (''string'')主题名。 | ||
; 'Title' : (''string'')如果定义了主题URI,主题名或者包含主题名的HTML段,会链接到主题的URI。 | ; 'Title' : (''string'')如果定义了主题URI,主题名或者包含主题名的HTML段,会链接到主题的URI。 | ||
; '描述' : (''string'')通过[[WordPress:Function_Reference/wptexturize|wptexturize]]传递后,包含主题描述的HTML片段。 | ; '描述' : (''string'')通过[[WordPress:Function_Reference/wptexturize|wptexturize]]传递后,包含主题描述的HTML片段。 | ||
; 'Author' : (''string'')如果定义了作者的URI,作者名或者包含作者名的HTML片段会链接到作者URI。 | ; 'Author' : (''string'')如果定义了作者的URI,作者名或者包含作者名的HTML片段会链接到作者URI。 | ||
; 'Version' : (''string'')主题的版本数字。 | ; 'Version' : (''string'')主题的版本数字。 | ||
; 'Template' : (''string'')如果存在母主题,这是母主题的名称。 | ; 'Template' : (''string'')如果存在母主题,这是母主题的名称。 | ||
; 'Status' : (''string'')默认为'发表' | ; 'Status' : (''string'')默认为'发表' |
2008年7月28日 (一) 09:32的版本
描述
返回主题文件的一组信息。
用法
%%% <?php $theme_data = get_theme_data($theme_filename); ?> %%%
例子
用法
从默认主题style.css中得到信息,并且如果存在的话,显示名称和链接进的作者,以及相关的URIs。
<?php $theme_data = get_theme_data(ABSPATH . 'wp-content/themes/default/style.css'); echo $theme_data['Title']; echo $theme_data['Author']; ?>
参数
返回值
函数返回一个数组,包含下面键入的信息。
- 'Name'
- (string)主题名。
- 'Title'
- (string)如果定义了主题URI,主题名或者包含主题名的HTML段,会链接到主题的URI。
- '描述'
- (string)通过wptexturize传递后,包含主题描述的HTML片段。
- 'Author'
- (string)如果定义了作者的URI,作者名或者包含作者名的HTML片段会链接到作者URI。
- 'Version'
- (string)主题的版本数字。
- 'Template'
- (string)如果存在母主题,这是母主题的名称。
- 'Status'
- (string)默认为'发表'