get_template_directory()获取当前主题所在的绝对目录路径

目录

描述

译文

检索当前主题目录

原文

Retrieves the absolute path to the directory of the current theme.

Note: Does not contain a trailing slash.

Returns an absolute server path (eg: /home/user/public_html/wp-content/themes/my_theme), not a URI.

In the case a child theme is being used, the absolute path to the parent theme directory will be returned. Use get_stylesheet_directory() to get the absolute path to the child theme directory.

To retrieve the URI of the stylesheet directory use get_stylesheet_directory_uri() instead.

get_template_directory() 描述

用法

<?php echo get_template_directory(); ?>

get_template_directory() 用法

参数

This tag has no parameters.

get_template_directory() 参数

返回值

(string

Absolute path to the directory of the current theme (without the trailing slash).

get_template_directory() 返回值

示例

Include a PHP file

get_template_directory() 示例

注意

get_template_directory() 注意

历史

添加于 版本: 1.5.0

get_template_directory() 历史

源文件

get_template_directory() 函数的代码位于 wp-includes/theme.php.

get_template_directory() 源文件

相关