get_template_directory

Retrieve current theme directory.

Description

(string) get_template_directory(); 

Returns (string)

Template directory path.


Usage

  1. if ( !function_exists( 'get_template_directory' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_template_directory(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function get_template_directory() { 
  2. $template = get_template(); 
  3. $theme_root = get_theme_root( $template ); 
  4. $template_dir = "$theme_root/$template"; 
  5.  
  6. /** 
  7. * Filters the current theme directory path. 
  8. * @since 1.5.0 
  9. * @param string $template_dir The URI of the current theme directory. 
  10. * @param string $template Directory name of the current theme. 
  11. * @param string $theme_root Absolute path to the themes directory. 
  12. */ 
  13. return apply_filters( 'template_directory', $template_dir, $template, $theme_root );