Skip to main content

wp core version

Overview

Print the installed WordPress version number. With --extra, also shows PHP, MySQL/MariaDB, and WP-CLI versions — a quick environment snapshot useful for support, auditing, and CI checks.

What It Does

wp core version reads the $wp_version variable from wp-includes/version.php and prints it. It does not connect to the database and runs even if WordPress is partially installed.

Syntax

wp core version [--extra]

Options & Flags

FlagDescription
--extraAlso display PHP version, MySQL/MariaDB version, and WP-CLI version

Basic Usage

Get WordPress version

wp core version

Output:

6.7.2

Get all version info

wp core version --extra

Output:

WordPress version: 6.7.2
PHP binary: /usr/bin/php8.2
PHP version: 8.2.15
php.ini used: /etc/php/8.2/cli/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 8.0.36 Distrib 8.0.36
SQL modes:
WP-CLI root dir: phar://wp-cli.phar
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /usr/local/bin
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.10.0

Real-World Scenarios

Scenario 1: Capture version in a script

WP_VER=$(wp core version)
echo "Current WordPress version: ${WP_VER}"

Scenario 2: CI/CD — enforce minimum version

MIN_VERSION="6.5.0"
CURRENT=$(wp core version)

if [ "$(printf '%s\n' "$MIN_VERSION" "$CURRENT" | sort -V | head -n1)" != "$MIN_VERSION" ]; then
echo "ERROR: WordPress ${CURRENT} is below minimum required ${MIN_VERSION}"
exit 1
fi
echo "Version check passed: ${CURRENT}"

Scenario 3: Audit all managed sites

SITES=("/var/www/site1" "/var/www/site2" "/var/www/site3")
for site in "${SITES[@]}"; do
VER=$(wp --path="$site" core version 2>/dev/null || echo "ERROR")
echo "${site}: WordPress ${VER}"
done

Scenario 4: Reinstall exact version after incident

CURRENT_VER=$(wp core version)
echo "Reinstalling WordPress ${CURRENT_VER}..."
wp core download --version="${CURRENT_VER}" --force
wp core verify-checksums

Scenario 5: Environment snapshot for support ticket

wp core version --extra > environment-info.txt
cat environment-info.txt

Comparison: What --extra adds

Informationwp core versionwp core version --extra
WordPress version
PHP version
PHP binary path
MySQL/MariaDB version
WP-CLI version
WP-CLI config paths

Best Practices

  1. Use in scripts to capture version dynamically — never hardcode the version number.
  2. Use --extra for support requests — gives the full environment picture.
  3. Run before and after updates to confirm version changed.
  4. Combine with wp core verify-checksums as a post-update health check.

Troubleshooting

ProblemCauseFix
Error: This does not seem to be a WordPress installRun from wrong directorycd /var/www/html or use --path
Version number looks wrongwp-includes/version.php corrupted/tamperedRun wp core verify-checksums
--extra shows wrong PHP versionMultiple PHP versions installedCheck which php and WP-CLI interpreter

Quick Reference

wp core version                          # WordPress version only
wp core version --extra # Full environment info
WP_VER=$(wp core version) # Capture in variable
wp --path=/var/www/html core version # Specific site path

Next Steps