Title: WP_Theme::get_block_template_folders
Published: November 8, 2023
Last modified: August 20, 2026

---

# WP_Theme::get_block_template_folders(): string[]

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_theme/get_block_template_folders/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_theme/get_block_template_folders/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_theme/get_block_template_folders/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_theme/get_block_template_folders/?output_format=md#changelog)

Returns the folder names of the block template directories.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_theme/get_block_template_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/classes/wp_theme/get_block_template_folders/?output_format=md#source)󠁿

    ```php
    public function get_block_template_folders() {
    	// Return set/cached value if available.
    	if ( isset( $this->block_template_folders ) ) {
    		return $this->block_template_folders;
    	}

    	$this->block_template_folders = $this->default_template_folders;

    	$stylesheet_directory = $this->get_stylesheet_directory();
    	// If the theme uses deprecated block template folders.
    	if ( file_exists( $stylesheet_directory . '/block-templates' ) || file_exists( $stylesheet_directory . '/block-template-parts' ) ) {
    		$this->block_template_folders = array(
    			'wp_template'      => 'block-templates',
    			'wp_template_part' => 'block-template-parts',
    		);
    	}
    	return $this->block_template_folders;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-theme.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-theme.php#L1806)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-theme.php#L1806-L1823)

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

| Uses | Description | 
| [WP_Theme::get_stylesheet_directory()](https://developer.wordpress.org/reference/classes/wp_theme/get_stylesheet_directory/)`wp-includes/class-wp-theme.php` |

Returns the absolute path to the directory of a theme’s “stylesheet” files.

  |

| Used by | Description | 
| [WP_Theme::__construct()](https://developer.wordpress.org/reference/classes/wp_theme/__construct/)`wp-includes/class-wp-theme.php` |

Constructor for [WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/).

  |

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

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

## User Contributed Notes

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