register_theme_directory()
Register a directory that can contain themes.
The $directory parameter specifies the path to the theme folder with no slash at the end. The specified path is added to the global array of $wp_theme_directories, which is then used when retrieving the path/URL to the WordPress themes folder.
No Hooks.
Return
true|false
. True if successfully registered a directory that contains themes, false if the directory does not exist.
Usage
register_theme_directory( $directory );
- $directory(string) (required)
- Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR.
Examples
#1 Make the plugin folder as a folder to the WordPress themes
/* * For the structure of the plugin of this kind: * * /my-plugin * /my-plugin.php * /themes/ * * This code should be placed in the file my-plugin.php. */ register_theme_directory( dirname( __FILE__ ) . '/themes' );
Notes
- Global. Array. $wp_theme_directories
Changelog
Since 2.9.0 | Introduced. |