get_theme_root

Home » Functions » get_theme_root

Function Name: get_theme_root

The get_theme_root function is a WordPress core function that retrieves the absolute path to the themes directory for the current site or network.

This function is useful when you need to get the path to the themes directory in order to load files or perform other actions related to themes.

The get_theme_root function accepts two optional parameters: $stylesheet_or_template and $blog_id. The $stylesheet_or_template parameter is used to specify whether to retrieve the path for the current theme or a parent theme, and the $blog_id parameter is used to specify the ID of the site in a multisite network.

Here is an example usage code:

$themes_dir = get_theme_root();
echo $themes_dir;

In this example, the $themes_dir variable will contain the absolute path to the themes directory for the current site or network, and the echo statement will output this path to the screen.

Overall, the get_theme_root function is a useful tool for WordPress developers who need to work with themes and their associated files.

Learn More on WordPress.org

WordPress snippets using the get_theme_root function

Register an account to save your snippets or go Pro to get more features.