Title: WP_Theme::exists
Published: April 25, 2014
Last modified: April 28, 2025

---

# WP_Theme::exists(): bool

## In this article

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

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

Determines whether the theme exists.

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

A theme with errors exists. A theme with the error of ‘theme_not_found’, meaning
that the theme’s directory was not found, does not exist.

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

 bool Whether the theme exists.

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

    ```php
    public function exists() {
    	return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes(), true ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-theme.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-theme.php#L767)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-theme.php#L767-L769)

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

| Uses | Description | 
| [WP_Theme::errors()](https://developer.wordpress.org/reference/classes/wp_theme/errors/)`wp-includes/class-wp-theme.php` |

Returns errors property.

  |

| Used by | Description | 
| [WP_Theme::get_pattern_cache()](https://developer.wordpress.org/reference/classes/wp_theme/get_pattern_cache/)`wp-includes/class-wp-theme.php` |

Gets block pattern cache.

  | 
| [WP_REST_Themes_Controller::get_item()](https://developer.wordpress.org/reference/classes/wp_rest_themes_controller/get_item/)`wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php` |

Retrieves a single theme.

  |

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

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

## User Contributed Notes

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