Wordpress 从样式表中获取主题名称
Wordpress get theme name from stylesheet
我想从样式表中获取 wordpress 主题名称 (style.css)。
例如这里是style.css:
/*
Theme Name: Campus
Theme URI: http://www.academiathemes.com/themes/campus/
Description: Campus is a free WordPress theme for blogs and review websites.
Author: AcademiaThemes.com
Author URI: http://www.academiathemes.com/
Version: 1.2.6
License: GNU General Public License v2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: blue, white, light, two-columns, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-menu, featured-images, theme-options, threaded-comments, translation-ready
Text Domain: campus
*/
"Theme Name: Campus" 必须存储在 PHP 变量中。
有什么想法吗?谢谢。
也许试试这个?:
$var = wp_get_theme();
wp_get_theme() 有效,但 get_stylesheet() 更快。
https://developer.wordpress.org/reference/functions/get_stylesheet/
我想从样式表中获取 wordpress 主题名称 (style.css)。
例如这里是style.css:
/*
Theme Name: Campus
Theme URI: http://www.academiathemes.com/themes/campus/
Description: Campus is a free WordPress theme for blogs and review websites.
Author: AcademiaThemes.com
Author URI: http://www.academiathemes.com/
Version: 1.2.6
License: GNU General Public License v2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: blue, white, light, two-columns, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-menu, featured-images, theme-options, threaded-comments, translation-ready
Text Domain: campus
*/
"Theme Name: Campus" 必须存储在 PHP 变量中。
有什么想法吗?谢谢。
也许试试这个?:
$var = wp_get_theme();
wp_get_theme() 有效,但 get_stylesheet() 更快。 https://developer.wordpress.org/reference/functions/get_stylesheet/