Skip to content

Instantly share code, notes, and snippets.

@WolfieZero
Created April 26, 2012 09:09
Show Gist options
  • Save WolfieZero/2497910 to your computer and use it in GitHub Desktop.
Save WolfieZero/2497910 to your computer and use it in GitHub Desktop.
WordPress: return theme directory
/**
* Place this function in your functions.php file to allow global access
* Update: 26 April 2012 11:35 - TEMPLATEPATH does the same job!
*/
/**
* Theme Directory
* Returns the directory of the theme from root
*
* @param boolean $echo=false [description]
* @return string Depending on $echo this will return or echo the theme directory
*/
function theme_dir($echo=false) {
$theme = explode('wp-content/themes/', get_bloginfo('template_url'));
$themeFolder = get_theme_root().'/'.$theme[1];
if ($echo)
echo $themeFolder;
else
return $themeFolder;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment