Title: is_blog_installed
Published: April 25, 2014
Last modified: February 24, 2026

---

# is_blog_installed(): bool

## In this article

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

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

Determines whether WordPress is already installed.

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

The cache will be checked first. If you have a cache plugin, which saves the cache
values, then this will work. If you use the default WordPress cache, and the database
goes away, then you might have problems.

Checks for the ‘siteurl’ option for whether WordPress is installed.

For more information on this and similar theme functions, check out the [ Conditional Tags](https://developer.wordpress.org/themes/basics/conditional-tags/)
article in the Theme Developer Handbook.

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

 bool Whether the site is already installed.

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

    ```php
    function is_blog_installed() {
    	global $wpdb;

    	/*
    	 * Check cache first. If options table goes away and we have true
    	 * cached, oh well.
    	 */
    	if ( wp_cache_get( 'is_blog_installed' ) ) {
    		return true;
    	}

    	$suppress = $wpdb->suppress_errors();

    	if ( ! wp_installing() ) {
    		$alloptions = wp_load_alloptions();
    	}

    	// If siteurl is not set to autoload, check it specifically.
    	if ( ! isset( $alloptions['siteurl'] ) ) {
    		$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
    	} else {
    		$installed = $alloptions['siteurl'];
    	}

    	$wpdb->suppress_errors( $suppress );

    	$installed = ! empty( $installed );
    	wp_cache_set( 'is_blog_installed', $installed );

    	if ( $installed ) {
    		return true;
    	}

    	// If visiting repair.php, return true and let it take over.
    	if ( defined( 'WP_REPAIRING' ) ) {
    		return true;
    	}

    	$suppress = $wpdb->suppress_errors();

    	/*
    	 * Loop over the WP tables. If none exist, then scratch installation is allowed.
    	 * If one or more exist, suggest table repair since we got here because the
    	 * options table could not be accessed.
    	 */
    	$wp_tables = $wpdb->tables();
    	foreach ( $wp_tables as $table ) {
    		// The existence of custom user tables shouldn't suggest an unwise state or prevent a clean installation.
    		if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE === $table ) {
    			continue;
    		}

    		if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE === $table ) {
    			continue;
    		}

    		$described_table = $wpdb->get_results( "DESCRIBE $table;" );
    		if (
    			( ! $described_table && empty( $wpdb->last_error ) ) ||
    			( is_array( $described_table ) && 0 === count( $described_table ) )
    		) {
    			continue;
    		}

    		// One or more tables exist. This is not good.

    		wp_load_translations_early();

    		// Die with a DB error.
    		$wpdb->error = sprintf(
    			/* translators: %s: Database repair URL. */
    			__( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ),
    			'maint/repair.php?referrer=is_blog_installed'
    		);

    		dead_db();
    	}

    	$wpdb->suppress_errors( $suppress );

    	wp_cache_set( 'is_blog_installed', false );

    	return false;
    }
    ```

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

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

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

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

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

Saves the data to the cache.

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

Attempts an early load of translations.

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

Loads custom DB error or display WordPress DB error.

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

Loads and caches all autoloaded options, if available or all options.

  | 
| [wpdb::suppress_errors()](https://developer.wordpress.org/reference/classes/wpdb/suppress_errors/)`wp-includes/class-wpdb.php` |

Enables or disables suppressing of database errors.

  | 
| [wpdb::tables()](https://developer.wordpress.org/reference/classes/wpdb/tables/)`wp-includes/class-wpdb.php` |

Returns an array of WordPress tables.

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

Retrieves the cache contents from the cache by key and group.

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

Retrieves the translation of $text.

  | 
| [wpdb::get_var()](https://developer.wordpress.org/reference/classes/wpdb/get_var/)`wp-includes/class-wpdb.php` |

Retrieves one value from the database.

  | 
| [wpdb::get_results()](https://developer.wordpress.org/reference/classes/wpdb/get_results/)`wp-includes/class-wpdb.php` |

Retrieves an entire SQL result set from the database (i.e., many rows).

  |

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

| Used by | Description | 
| [wp_upgrade()](https://developer.wordpress.org/reference/functions/wp_upgrade/)`wp-admin/includes/upgrade.php` |

Runs WordPress Upgrade functions.

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

Redirects to the installer if WordPress is not installed.

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

Registers all of the default WordPress widgets on startup.

  |

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

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

## User Contributed Notes

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