Skip to main content

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

FlagDescription
--networkCheck 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 CodeMeaning
0WordPress is installed
1WordPress 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

  1. Always guard wp core install with wp core is-installed in idempotent scripts.
  2. Redirect stderr with 2>/dev/null when WordPress might not be set up yet (e.g., in Docker entrypoints).
  3. Use --network when managing multisites to verify network-level installation.
  4. Combine with --path to check multiple sites in a loop.

Troubleshooting

ProblemCauseFix
Always returns not installedwp-config.php missing or DB unreachableVerify config and DB connectivity
Unexpected exit 0 on fresh siteDB tables exist from a previous installCheck with wp db tables
Permission errorWP-CLI user can't read filesFix 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