The is_blog_installed() WordPress PHP function determines whether WordPress is already installed.
Usage
if (is_blog_installed()) { // Your code here, if WordPress is installed } else { // Your code here, if WordPress is not installed }
Parameters
- None
More information
See WordPress Developer Resources: is_blog_installed()
Examples
Redirecting to the installation page if WordPress is not installed
This example checks if WordPress is installed and redirects the user to the installation page if it is not installed.
if (!is_blog_installed()) { header('Location: wp-admin/install.php'); exit; }
Displaying a message if WordPress is installed
This example displays a message on the screen if WordPress is installed.
if (is_blog_installed()) { echo 'WordPress is installed!'; }
Creating a custom function to check WordPress installation status
This example creates a custom function that returns a boolean value depending on whether WordPress is installed or not.
function check_wordpress_installation() { return is_blog_installed(); } if (check_wordpress_installation()) { echo 'WordPress is installed.'; } else { echo 'WordPress is not installed.'; }
Displaying different content based on the installation status
This example displays different content on a page based on whether WordPress is installed or not.
if (is_blog_installed()) { echo '<h2>Welcome to the installed WordPress site!</h2>'; } else { echo '<h2>Please install WordPress to get started.</h2>'; }
Logging the installation status
This example logs the installation status of WordPress to a text file.
$log_file = 'installation_log.txt'; if (is_blog_installed()) { file_put_contents($log_file, "WordPress is installed.\n", FILE_APPEND); } else { file_put_contents($log_file, "WordPress is not installed.\n", FILE_APPEND); }