Using WordPress ‘is_theme_paused()’ PHP function

The is_theme_paused() WordPress PHP function determines whether a theme is technically active but was paused while loading.

Usage

$is_paused = is_theme_paused( $theme );

Parameters

  • $theme (string) – Required. Path to the theme directory relative to the themes directory.

More information

See WordPress Developer Resources: is_theme_paused()

Examples

Check if a theme is paused

This example checks if the specified theme is paused and displays a message accordingly.

$theme = 'my-theme';
$is_paused = is_theme_paused($theme);

if ($is_paused) {
    echo 'The theme is paused.';
} else {
    echo 'The theme is not paused.';
}

Display paused themes

This example displays a list of all themes that are paused.

$all_themes = wp_get_themes();
$paused_themes = array();

foreach ($all_themes as $theme_name => $theme_object) {
    if (is_theme_paused($theme_name)) {
        $paused_themes[] = $theme_name;
    }
}

echo 'Paused Themes: ' . implode(', ', $paused_themes);

Resume paused themes

This example resumes all paused themes.

$all_themes = wp_get_themes();

foreach ($all_themes as $theme_name => $theme_object) {
    if (is_theme_paused($theme_name)) {
        resume_theme($theme_name);
    }
}

Pause non-paused themes

This example pauses all themes that are not paused.

$all_themes = wp_get_themes();

foreach ($all_themes as $theme_name => $theme_object) {
    if (!is_theme_paused($theme_name)) {
        pause_theme($theme_name);
    }
}

Toggle theme pause state

This example toggles the pause state of a specified theme.

$theme = 'my-theme';

if (is_theme_paused($theme)) {
    resume_theme($theme);
    echo 'Theme resumed.';
} else {
    pause_theme($theme);
    echo 'Theme paused.';
}