Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_get_block_templates_paths( string $base_directory )

Finds all nested template part file paths in a theme’s directory.



(string) (Required) The theme's file path.

Top ↑


(array) A list of paths to all template part files.

Top ↑


File: wp-includes/block-template-utils.php

function _get_block_templates_paths( $base_directory ) {
	$path_list = array();
	if ( file_exists( $base_directory ) ) {
		$nested_files      = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) );
		$nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH );
		foreach ( $nested_html_files as $path => $file ) {
			$path_list[] = $path;
	return $path_list;

Top ↑


Version Description
5.9.0 Introduced.

Top ↑

User Contributed Notes

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