wp_is_block_theme()
Checks if the current theme is a block theme (created with the block editor).
To determine if a theme is a block theme or not, the function checks for the presence of the following files relative to the theme root:
- /block-templates/index.html
- /templates/index.html
This is a wrapper for the method WP_Theme()->is_block_theme().
A theme is considered a block theme if its template is made using the block editor (Gutenberg). Since version 5.9, it has become possible to make the entire theme template in blocks.
No Hooks.
Returns
true|false. Depends on whether the theme works with blocks or not.
Usage
wp_is_block_theme();
Examples
#1 Check if it's block theme or not
if( wp_is_block_theme() ){
echo 'The current theme is blocky.';
}
else {
echo 'The current theme is not a block theme';
}
Changelog
| Since 5.9.0 | Introduced. |
wp_is_block_theme() wp is block theme code WP 6.8.3
function wp_is_block_theme() {
if ( empty( $GLOBALS['wp_theme_directories'] ) ) {
_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before the theme directory is registered.' ), '6.8.0' );
return false;
}
return wp_get_theme()->is_block_theme();
}