register_theme_directory() WP 2.9.0
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. |
Code of register_theme_directory() register theme directory WP 5.6
Related Functions
From tag: theme path (theme folder url)
More from category: Other Theme Functions
- add_theme_support()
- bloginfo()
- body_class()
- current_theme_supports()
- get_custom_header_markup()
- get_custom_logo()
- get_header_image()
- get_header_image_tag()
- get_header_textcolor()
- get_header_video_url()
- get_page_templates()
- get_post_class()
- get_query_template()
- get_stylesheet()
- get_template()
- get_theme_mod()
- get_theme_mods()
- has_custom_logo()
- has_header_image()
- has_header_video()
- is_child_theme()
- is_header_video_active()
- is_multi_author()
- post_class()
- register_nav_menu()
- register_nav_menus()
- remove_theme_mod()
- remove_theme_mods()
- remove_theme_support()
- search_theme_directories()
- set_theme_mod()
- single_month_title()
- the_custom_header_markup()
- the_custom_logo()