register_theme_directory

Register a directory that contains themes.

Description

register_theme_directory( (string) $directory ); 

Parameters (1)

0. $directory (string)
Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR

Usage

  1. if ( !function_exists( 'register_theme_directory' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR 
  5. $directory = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = register_theme_directory($directory); 
  9.  

Defined (1)

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

/wp-includes/theme.php  
  1. function register_theme_directory( $directory ) { 
  2. global $wp_theme_directories; 
  3.  
  4. if ( ! file_exists( $directory ) ) { 
  5. // Try prepending as the theme directory could be relative to the content directory 
  6. $directory = WP_CONTENT_DIR . '/' . $directory; 
  7. // If this directory does not exist, return and do not register 
  8. if ( ! file_exists( $directory ) ) { 
  9. return false; 
  10.  
  11. if ( ! is_array( $wp_theme_directories ) ) { 
  12. $wp_theme_directories = array(); 
  13.  
  14. $untrailed = untrailingslashit( $directory ); 
  15. if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) { 
  16. $wp_theme_directories[] = $untrailed; 
  17.  
  18. return true;