template_directory

Filters the current theme directory path.

Description

apply_filters( 'template_directory', (string) $template_dir, (string) $template, (string) $theme_root ); 

Parameters (3)

0. $template_dir (string)
The URI of the current theme directory.
1. $template (string)
Directory name of the current theme.
2. $theme_root (string)
Absolute path to the themes directory.

Usage

To run the hook, copy the example below.
  1. $template_dir = apply_filters( 'template_directory', $template_dir, $template, $theme_root ); 
  2.  
  3. if ( !empty( $template_dir ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the template_directory callback 
  2. function filter_template_directory( $template_dir, $template, $theme_root ) { 
  3. // make filter magic happen here... 
  4. return $template_dir
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'template_directory', 'filter_template_directory', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'template_directory', 'filter_template_directory', 10, 3 ); 

Defined (1)

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

/wp-includes/theme.php  
  1. return apply_filters( 'template_directory', $template_dir, $template, $theme_root );