Title: get_block_theme_folders
Published: February 3, 2022
Last modified: May 20, 2026

---

# get_block_theme_folders( string $theme_stylesheet = null ): string[]

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#wp--skip-link--target)

For backward compatibility reasons, block themes might be using block-templates 
or block-template-parts, this function ensures we fallback to these folders properly.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#parameters)󠁿

 `$theme_stylesheet`stringoptional

The stylesheet. Default is to leverage the main theme root.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#return)󠁿

 string[] Folder names used by block themes.

 * `wp_template` string
 * Theme-relative directory name for block templates.
 * `wp_template_part` string
 * Theme-relative directory name for block template parts.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#source)󠁿

    ```php
    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();
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/block-template-utils.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/block-template-utils.php#L42)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/block-template-utils.php#L42-L52)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_theme()](https://developer.wordpress.org/reference/functions/wp_get_theme/)`wp-includes/theme.php` |

Gets a [WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/) object for a theme.

  |

| Used by | Description | 
| [_get_block_template_file()](https://developer.wordpress.org/reference/functions/_get_block_template_file/)`wp-includes/block-template-utils.php` |

Retrieves the template file from the theme for a given slug.

  | 
| [_get_block_templates_files()](https://developer.wordpress.org/reference/functions/_get_block_templates_files/)`wp-includes/block-template-utils.php` |

Retrieves the template files from the theme.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_block_theme_folders/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_block_theme_folders%2F)
before being able to contribute a note or feedback.