Title: wp_get_active_and_valid_themes
Published: February 22, 2019
Last modified: May 20, 2026

---

# wp_get_active_and_valid_themes(): string[]

## In this article

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

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_active_and_valid_themes/?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.

Retrieves an array of active and valid themes.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_get_active_and_valid_themes/?output_format=md#description)󠁿

While upgrading or installing WordPress, no themes are returned.

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

 string[] Array of absolute paths to theme directories.

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

    ```php
    function wp_get_active_and_valid_themes() {
    	global $pagenow, $wp_stylesheet_path, $wp_template_path;

    	$themes = array();

    	if ( wp_installing() && 'wp-activate.php' !== $pagenow ) {
    		return $themes;
    	}

    	if ( is_child_theme() ) {
    		$themes[] = $wp_stylesheet_path;
    	}

    	$themes[] = $wp_template_path;

    	/*
    	 * Remove themes from the list of active themes when we're on an endpoint
    	 * that should be protected against WSODs and the theme is paused.
    	 */
    	if ( wp_is_recovery_mode() ) {
    		$themes = wp_skip_paused_themes( $themes );

    		// If no active and valid themes exist, skip loading themes.
    		if ( empty( $themes ) ) {
    			add_filter( 'wp_using_themes', '__return_false' );
    		}
    	}

    	return $themes;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/load.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/load.php#L1096)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/load.php#L1096-L1125)

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

| Uses | Description | 
| [wp_is_recovery_mode()](https://developer.wordpress.org/reference/functions/wp_is_recovery_mode/)`wp-includes/load.php` |

Determines whether WordPress is in Recovery Mode.

  | 
| [wp_skip_paused_themes()](https://developer.wordpress.org/reference/functions/wp_skip_paused_themes/)`wp-includes/load.php` |

Filters a given list of themes, removing any paused themes from it.

  | 
| [wp_installing()](https://developer.wordpress.org/reference/functions/wp_installing/)`wp-includes/load.php` |

Checks or sets whether WordPress is in “installation” mode.

  | 
| [is_child_theme()](https://developer.wordpress.org/reference/functions/is_child_theme/)`wp-includes/theme.php` |

Whether a child theme is in use.

  | 
| [add_filter()](https://developer.wordpress.org/reference/functions/add_filter/)`wp-includes/plugin.php` |

Adds a callback function to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_get_active_and_valid_themes/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_get_active_and_valid_themes/?output_format=md#)

| Used by | Description | 
| [_register_theme_block_patterns()](https://developer.wordpress.org/reference/functions/_register_theme_block_patterns/)`wp-includes/block-patterns.php` |

Register any patterns that the active theme may provide under its `./patterns/` directory.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_active_and_valid_themes/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.1.0](https://developer.wordpress.org/reference/since/5.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_active_and_valid_themes%2F)
before being able to contribute a note or feedback.