从 Wordpress 中的 style.css 文件获取主题信息
对于 WordPress 主题,需要将信息添加到 style.css 文件的顶部:
例如;对于默认主题,有这样的:
/*
Theme Name: WordPress Default
Theme URI: http://wordpress.org/
Description: The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>.
Version: 1.6
Author: Michael Heilemann
Author URI: http://binarybonsai.com/
Tags: blue, custom header, fixed width, two columns, widgets
*/
是否有任何 WordPress 函数可以以编程方式获取此信息?
With a Wordpress theme, it is necessary to add information to the top of the style.css file:
e.g; for the default theme there is this:
/*
Theme Name: WordPress Default
Theme URI: http://wordpress.org/
Description: The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>.
Version: 1.6
Author: Michael Heilemann
Author URI: http://binarybonsai.com/
Tags: blue, custom header, fixed width, two columns, widgets
*/
Are there any wordpress functions to get this information programatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
get_theme_data
get_theme_data
您可以使用
get_theme_data()
或我快速整理的这个 PHP 脚本:You could use
get_theme_data()
or this PHP script I put together quickly:请注意,
get_theme_data
函数在 WP 3.4 中已弃用,并替换为wp_get_theme
。替换函数不会像get_theme_data
那样从styles.css
检索所有相同的元素,特别是ThemeURI
元素现在返回主题的目录,不是主题 URL
的值。http://codex.wordpress.org/Function_Reference/wp_get_theme
Note that
get_theme_data
function was deprecated in WP 3.4 and replaced withwp_get_theme
. The replacement function does not retrieve all of the same elements fromstyles.css
asget_theme_data
did, specifically theThemeURI
element now returns the theme’s directory, not the value ofTheme URL
.http://codex.wordpress.org/Function_Reference/wp_get_theme