WordPress: Function Reference/get theme data:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
第1行: 第1行:
== Description ==
== 描述==
== 描述==
Returns an array of information about a theme file.


返回主题文件的一组信息。
返回主题文件的一组信息。
== Usage ==


== 用法 ==
== 用法 ==


%%% <?php $theme_data = get_theme_data($theme_filename); ?> %%%
%%% <?php $theme_data = get_theme_data($theme_filename); ?> %%%
%%% <?php $theme_data = get_theme_data($theme_filename); ?> %%%
== Example ==


== 例子 ==
== 例子 ==
=== Usage ===


=== 用法 ===
=== 用法 ===
Get the information from the default themes style.css and display the Name and author linked with there respective URIs if they exist.


从默认主题style.css中得到信息,并且如果存在的话,显示名称和链接进的作者,以及相关的URIs。
从默认主题style.css中得到信息,并且如果存在的话,显示名称和链接进的作者,以及相关的URIs。
第34行: 第20行:
?>
?>
</pre>
</pre>
<pre>
<?php
    $theme_data = get_theme_data(ABSPATH . 'wp-content/themes/default/style.css');
    echo $theme_data['Title'];
    echo $theme_data['Author'];
?>
</pre>
== Parameters ==
== 参数 ==
== 参数 ==
{{Parameter|$theme_filename|string|Path and filename of the theme's <tt>style.css</tt>.}}


{{Parameter|$theme_filename|string|主题的 <tt>style.css</tt>路径和文件名。}}
{{Parameter|$theme_filename|string|主题的 <tt>style.css</tt>路径和文件名。}}


== Return values ==
==返回值 ==
==返回值 ==
The function returns an array containing the following keyed information.


函数返回一个数组,包含下面键入的信息。
函数返回一个数组,包含下面键入的信息。
; 'Name' : (''string'') The Themes name.
; 'Name' : (''string'')主题名。
; 'Name' : (''string'')主题名。
; 'Title' : (''string'') Either the Theme's name or a HTML fragment containg the Theme's name linked to the Theme's URI if the Theme's URI is defined.


; 'Title' : (''string'')如果定义了主题URI,主题名或者包含主题名的HTML段,会链接到主题的URI。
; 'Title' : (''string'')如果定义了主题URI,主题名或者包含主题名的HTML段,会链接到主题的URI。
; 'Description' : (''string'') A HTML fragment containg the Themes description after it has passed through [[WordPress:Function_Reference/wptexturize|wptexturize]].


; '描述' : (''string'')通过[[WordPress:Function_Reference/wptexturize|wptexturize]]传递后,包含主题描述的HTML片段。
; '描述' : (''string'')通过[[WordPress:Function_Reference/wptexturize|wptexturize]]传递后,包含主题描述的HTML片段。
; 'Author' : (''string'') Either the Author's name or a HTML fragment containg the Author's name linked to the Author's URI if the Author's URI is defined.


; 'Author' : (''string'')如果定义了作者的URI,作者名或者包含作者名的HTML片段会链接到作者URI。
; 'Author' : (''string'')如果定义了作者的URI,作者名或者包含作者名的HTML片段会链接到作者URI。
; 'Version' : (''string'') The Theme's version number.


; 'Version' : (''string'')主题的版本数字。
; 'Version' : (''string'')主题的版本数字。
; 'Template' : (''string'') The name of the parent Theme if one exists. 
; 'Template' : (''string'')如果存在母主题,这是母主题的名称。
; 'Template' : (''string'')如果存在母主题,这是母主题的名称。


; 'Status' : (''string'') defaults to 'publish'
; '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)默认为'发表'