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()

Return 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.

2 calls to path_to_theme()
phptemplate_get_ie_styles in themes/garland/template.php
Generates IE CSS links for LTR and RTL languages.
template_preprocess in includes/theme.inc
Adds a default set of helper variables for preprocess functions and templates. This comes in before any other preprocess function which makes it possible to be used in default theme implementations (non-overriden theme functions).


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


function path_to_theme() {
  global $theme_path;

  if (!isset($theme_path)) {

  return $theme_path;


brankoc’s picture

To get the path to another module or theme, use drupal_get_path().

gthing’s picture

Example usage:

<img src="/<?php print path_to_theme(); ?>/img/whatever.png"  />

path_to_theme() will return something similar to:


You will need to include leading and trailing slashes in the case of the above example.

codycraven’s picture

It should actually be:

<img src="<?php print base_path() . path_to_theme(); ?>/img/whatever.png"  />

Otherwise if Drupal is installed in a sub-directory of the domain the path will point to an invalid location.

dgorton’s picture

In some situations path_to_theme() will return the path to the base_theme. More info & discussions at http://drupal.org/node/1026156

Caught me by surprise - hope it helps someone else as well!