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

---

# _get_block_templates_paths( string $base_directory ): string[]

## In this article

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

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

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

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

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

 `$base_directory`stringrequired

The theme’s file path.

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

 string[] A list of paths to all template part files.

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

    ```php
    function _get_block_templates_paths( $base_directory ) {
    	static $template_path_list = array();
    	if ( isset( $template_path_list[ $base_directory ] ) ) {
    		return $template_path_list[ $base_directory ];
    	}
    	$path_list = array();
    	if ( is_dir( $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;
    		}
    	}
    	$template_path_list[ $base_directory ] = $path_list;
    	return $path_list;
    }
    ```

[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#L297)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/block-template-utils.php#L297-L312)

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

| Used by | Description | 
| [_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_templates_paths/?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%2F_get_block_templates_paths%2F)
before being able to contribute a note or feedback.