WordPress at Your Fingertips
function is not described

WP_Theme::get_files() public WP 3.4.0

Return files in the theme's directory.

{} It's a method of the class: WP_Theme{}

No Hooks.


String[]. Array of files, keyed by the path to the file relative to the theme's directory, with the values being absolute paths.


$WP_Theme = new WP_Theme();
$WP_Theme->get_files( $type, $depth, $search_parent );
Array of extensions to find, string of a single extension, or null for all extensions.
Default: null
How deep to search for files.
-1 depth is infinite.
Default: flat scan (0 depth)
Whether to return parent files.
Default: false


Since 3.4.0 Introduced.

Code of WP_Theme::get_files() WP 5.8

public function get_files( $type = null, $depth = 0, $search_parent = false ) {
	$files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );

	if ( $search_parent && $this->parent() ) {
		$files += (array) self::scandir( $this->get_template_directory(), $type, $depth );

	return $files;