WP_Theme::get_block_template_folders(): string[]

In this article

Returns the folder names of the block template directories.

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

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

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.