Languages: English • Reference/get theme root 日本語 (Add your language)
Retrieves the absolute path to the themes directory, without the trailing slash.
<?php get_theme_root( $stylesheet_or_template ); ?>
The function below informs about the number of subdirectories in the themes directory. Note that this doesn't necessarily match the number of themes recognized by 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"; } ?>
Example output:
Since: 1.5.0
get_theme_root() is located in wp-includes/theme.php
.
Theme paths: get_template(), get_template_directory(), get_template_directory_uri(), get_theme_roots(), get_theme_root(), get_theme_root_uri(), get_stylesheet(), get_stylesheet_uri(), get_stylesheet_directory(), get_stylesheet_directory_uri(), get_bloginfo(), get_theme_file_uri(), get_theme_file_path()