get_block_theme_folders()
For backward compatibility reasons, block themes might be using block-templates or block-template-parts, this function ensures we fallback to these folders properly.
No Hooks.
Return
String[]
. Folder names used by block themes.
Usage
get_block_theme_folders( $theme_stylesheet );
- $theme_stylesheet(string)
- The stylesheet.
Default: to leverage the main theme root
Changelog
Since 5.9.0 | Introduced. |
get_block_theme_folders() get block theme folders code WP 6.6.2
function get_block_theme_folders( $theme_stylesheet = null ) { $theme = wp_get_theme( (string) $theme_stylesheet ); if ( ! $theme->exists() ) { // Return the default folders if the theme doesn't exist. return array( 'wp_template' => 'templates', 'wp_template_part' => 'parts', ); } return $theme->get_block_template_folders(); }