4.6.x theme.inc path_to_theme()
4.7.x theme.inc path_to_theme()
5.x theme.inc path_to_theme()
6.x theme.inc path_to_theme()
7.x theme.inc path_to_theme()

Returns the path to the current themed element.

It can point to the active theme or the module handling a themed implementation. For example, when invoked within the scope of a theming call it will depend on where the theming function is handled. If implemented from a module, it will point to the module. If implemented from the active theme, it will point to the active theme. When called outside the scope of a theming call, it will always point to the active theme.

4 calls to path_to_theme()
bartik_preprocess_html in themes/bartik/template.php
Add body classes if certain regions have content.
garland_preprocess_html in themes/garland/template.php
Override or insert variables into the html template.
seven_preprocess_html in themes/seven/template.php
Override or insert variables into the html template.
template_preprocess in includes/theme.inc
Adds a default set of helper variables for variable processors and templates.


includes/theme.inc, line 1227
The theme system, which controls the output of Drupal.


function path_to_theme() {
  global $theme_path;
  if (!isset($theme_path)) {
  return $theme_path;


dvessel’s picture

…and not the themed element, use:

  drupal_get_path('theme', 'THEME_NAME');

The path returned with path_to_theme() depends on where and when it's called which can be hard to predict. It's usually fine in most cases but if you're getting unpredictable results use drupal_get_path().

wbjin’s picture

I was calling path_to_theme in block--system--main.tpl.php and for some reason it was giving me garland (I was sub-theming garland). drupal_get_path works much better.

brian_c’s picture

To automatically determine the path to the current active theme, you can use:

altavis’s picture

Absolutely the best approach. Seems to work everywhere, even in subtheme with field.tpl.php placed in the base theme.

ParisLiakos’s picture

if you use different theme for the admin area you get that theme instead...

So, is there any way to get the path,or at least,the name of the current frontend theme and not the administration one?

mishly’s picture

Try this:

$theme_path = drupal_get_path('theme', variable_get('theme_default', NULL));

It should return the path to the default theme. Handy when you have different front-end and back-end themes.


jhr’s picture

Works. mishly++

z3cka’s picture

I used HOOK_theme() in my module to provide a tpl. When calling path_to_theme() in said tpl it returned the path to the module, not the enabled theme.

The solution was to use drupal_get_path().


nedim.hadzimahmutovic’s picture

If you are missing page.tpl.php in your theme, path_to_theme() will return modules/system path instead oh theme path.

zeves’s picture

when do node_save inside block_view - block_view is executed twice

I'm trying to get statistic for banner in block and it's necessary to save in block.
How to solve the problem ?

yannickoo’s picture


JFeltkamp’s picture

Thx, that's what I'm looking for :-)