wp core is-installed
Overview
A lightweight check that returns true (exit code 0) if WordPress is installed and the database tables exist, or exits with code 1 if not. Designed for use in scripts and conditionals.
What It Does
wp core is-installed checks whether WordPress has been installed by verifying the presence of core database tables (specifically the wp_options table with siteurl). It produces no output on success — just an exit code.
Syntax
wp core is-installed [--network]
Options & Flags
| Flag | Description |
|---|---|
--network | Check if multisite is installed (not just a single site) |
Basic Usage
Check if installed (silent)
wp core is-installed
echo "Exit code: $?"
# 0 = installed, 1 = not installed
Use in a conditional
if wp core is-installed; then
echo "WordPress is installed."
else
echo "WordPress is not installed."
fi
Check for multisite installation
if wp core is-installed --network; then
echo "Multisite is configured."
fi
Exit Codes
| Exit Code | Meaning |
|---|---|
0 | WordPress is installed |
1 | WordPress is NOT installed |
Real-World Scenarios
Scenario 1: Idempotent Docker entrypoint
#!/bin/bash
if ! wp core is-installed --allow-root 2>/dev/null; then
echo "Installing WordPress..."
wp core install \
--url="http://localhost" \
--title="My Site" \
--admin_user=admin \
--admin_password=admin \
--admin_email=admin@localhost \
--skip-email
fi
echo "WordPress is ready."
Scenario 2: CI/CD pre-flight check
# Abort pipeline if site is not installed
if ! wp core is-installed; then
echo "ERROR: WordPress is not installed. Aborting."
exit 1
fi
# Continue with deployment
wp plugin update --all
wp core update
Scenario 3: Provisioning script (only install once)
wp core download
wp config create --dbname=mydb --dbuser=root --dbpass=secret
wp db create
if ! wp core is-installed; then
wp core install \
--url="${SITE_URL}" \
--title="${SITE_TITLE}" \
--admin_user="${ADMIN_USER}" \
--admin_password="${ADMIN_PASS}" \
--admin_email="${ADMIN_EMAIL}" \
--skip-email
fi
Scenario 4: Monitoring / health check script
#!/bin/bash
SITES=("/var/www/site1" "/var/www/site2" "/var/www/site3")
for site in "${SITES[@]}"; do
if wp --path="$site" core is-installed 2>/dev/null; then
echo "✅ $site — installed"
else
echo "❌ $site — NOT installed"
fi
done
Best Practices
- Always guard
wp core installwithwp core is-installedin idempotent scripts. - Redirect stderr with
2>/dev/nullwhen WordPress might not be set up yet (e.g., in Docker entrypoints). - Use
--networkwhen managing multisites to verify network-level installation. - Combine with
--pathto check multiple sites in a loop.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| Always returns not installed | wp-config.php missing or DB unreachable | Verify config and DB connectivity |
| Unexpected exit 0 on fresh site | DB tables exist from a previous install | Check with wp db tables |
| Permission error | WP-CLI user can't read files | Fix ownership or run as correct user |
Quick Reference
wp core is-installed # Check single site (silent)
wp core is-installed --network # Check multisite
wp core is-installed && echo "Ready" # Inline conditional
if ! wp core is-installed; then ... # Guard block
Next Steps
wp core install— install WordPress if not installed.wp core version— get the WordPress version when installed.wp core update— update WordPress after confirming it's installed.