Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
get_theme_root() - 检索主题目录的路径 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / get_theme_root()

get_theme_root( string $stylesheet_or_template = '' )

检索主题目录的路径


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "d2713afcb95042289f4c84b70dea616a" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "3a41fd57de8104db46dad2693d7f2deb" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

root

theme 主题more...


描述

没有尾随斜杠。


参数

$stylesheet_or_template

(string)(可选) 主题的样式表或模板名称。默认情况下是利用主主题根。

默认值: ''


返回

(string) 主题目录路径。



源码

查看源码 官方文档


更新日志

版本描述
1.5.0开始引入

使用示例

  • 示例1

    主题目录中的子目录数
    下面的函数通知主题目录中子目录的数量。请注意,这不一定与WordPress识别的主题数量匹配。

    <?php
    function display_themes_subdirs_count_info()
      $theme_root = get_theme_root();
      $files_array = glob("$theme_root/*", GLOB_ONLYDIR);
      echo "There are " . count($files_array) . " subdirectories in the " . $theme_root . " directory"; 
    }
    ?>
    

    示例输出:

    There are 5 subdirectories in the /home/user/public_html/wp-content/themes directory.