Using WordPress ‘get_raw_theme_root()’ PHP function

The get_raw_theme_root() WordPress PHP function gets the raw theme root relative to the content directory with no filters applied.

Usage

get_raw_theme_root( $stylesheet_or_template, $skip_cache = false );

Parameters

  • $stylesheet_or_template (string) – The stylesheet or template name of the theme.
  • $skip_cache (bool) – Optional. Whether to skip the cache. Defaults to false, meaning the cache is used. Default: false.

More information

See WordPress Developer Resources: get_raw_theme_root()

Examples

Get the raw theme root of the active theme

$active_theme = get_stylesheet();
$theme_root = get_raw_theme_root($active_theme);
echo "Raw theme root: " . $theme_root;

Get the raw theme root of a specific theme

$specific_theme = 'my-custom-theme';
$theme_root = get_raw_theme_root($specific_theme);
echo "Raw theme root: " . $theme_root;

Get the raw theme root of a child theme

$child_theme = 'parent-theme-child';
$theme_root = get_raw_theme_root($child_theme);
echo "Raw theme root: " . $theme_root;

Get the raw theme root and skip the cache

$theme_name = 'my-theme';
$theme_root = get_raw_theme_root($theme_name, true);
echo "Raw theme root (cache skipped): " . $theme_root;

Display the full theme path

$theme = get_stylesheet();
$raw_theme_root = get_raw_theme_root($theme);
$content_dir = content_url();
$full_path = $content_dir . $raw_theme_root . '/' . $theme;
echo "Full theme path: " . $full_path;