Skip to main content

wp theme mod

Overview

Control theme Customizer settings from the CLI. This command lets you get, set, and delete theme_mod values — which handle everything from header images to custom colors and layout toggles.

Subcommands

CommandDescription
wp theme mod listList all mods for the active theme
wp theme mod get NAMERetrieve a specific mod value
wp theme mod set NAME VALUEUpdate a mod
wp theme mod remove NAMEDelete a mod

Basic Usage

List all mods

wp theme mod list

Set a custom color

wp theme mod set background_color "#000000"

Get a specific mod

wp theme mod get header_image

Real-World Scenarios

Scenario 1: Syncing Customizer Settings Between Enviroments

# Export from staging
wp @staging theme mod list --format=json > mods.json

# Import to production (looping)
# Note: Bulk import isn't native, so we script it
cat mods.json | jq -r 'to_entries[] | "\(.key) \(.value)"' | while read key value; do
wp @production theme mod set "$key" "$value"
done

Scenario 2: Resetting Theme Mods

# Wipe all customizer changes for a clean start
for mod in $(wp theme mod list --field=key); do
wp theme mod remove "$mod"
done

Quick Reference

wp theme mod list                      # List all
wp theme mod set <name> <value> # Set one
wp theme mod remove <name> # Delete one

Next Steps