WP_Theme::get_block_template_folders()publicWP 6.4.0

Returns the folder names of the block template directories.

Method of the class: WP_Theme{}

No Hooks.

Return

String[]. Folder names used by block themes.

Usage

$WP_Theme = new WP_Theme();
$WP_Theme->get_block_template_folders();

Changelog

Since 6.4.0 Introduced.

WP_Theme::get_block_template_folders() code WP 6.7.2

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;
}