Title: resume_theme
Published: May 7, 2019
Last modified: February 24, 2026

---

# resume_theme( string $theme, string $redirect ): bool|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

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

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

Tries to resume a single theme.

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

If a redirect was provided and a functions.php file was found, we first ensure that
functions.php file does not throw fatal errors anymore.

The way it works is by setting the redirection to the error before trying to include
the file. If the theme fails, then the redirection will not be overwritten with 
the success message and the theme will not be resumed.

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

 `$theme`stringrequired

Single theme to resume.

`$redirect`stringoptional

URL to redirect to. Default empty string.

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

 bool|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) True
on success, false if `$theme` was not paused, `WP_Error` on failure.

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

    ```php
    function resume_theme( $theme, $redirect = '' ) {
    	global $wp_stylesheet_path, $wp_template_path;

    	list( $extension ) = explode( '/', $theme );

    	/*
    	 * We'll override this later if the theme could be resumed without
    	 * creating a fatal error.
    	 */
    	if ( ! empty( $redirect ) ) {
    		$functions_path = '';
    		if ( str_contains( $wp_stylesheet_path, $extension ) ) {
    			$functions_path = $wp_stylesheet_path . '/functions.php';
    		} elseif ( str_contains( $wp_template_path, $extension ) ) {
    			$functions_path = $wp_template_path . '/functions.php';
    		}

    		if ( ! empty( $functions_path ) ) {
    			wp_redirect(
    				add_query_arg(
    					'_error_nonce',
    					wp_create_nonce( 'theme-resume-error_' . $theme ),
    					$redirect
    				)
    			);

    			// Load the theme's functions.php to test whether it throws a fatal error.
    			ob_start();
    			if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
    				define( 'WP_SANDBOX_SCRAPING', true );
    			}
    			include $functions_path;
    			ob_clean();
    		}
    	}

    	$result = wp_paused_themes()->delete( $extension );

    	if ( ! $result ) {
    		return new WP_Error(
    			'could_not_resume_theme',
    			__( 'Could not resume the theme.' )
    		);
    	}

    	return true;
    }
    ```

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

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

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

Get the instance for storing paused extensions.

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

Redirects to another page.

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

Retrieves the translation of $text.

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

Creates a cryptographic token tied to a specific action, user, user session, and window of time.

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

Retrieves a modified URL query string.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

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

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

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

## User Contributed Notes

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