1

I'm looking for a way to update multiple options via a single update command. The documentation only suggests the following usage:

wp option update <key> <new_value>

Does WP-CLI accept multiple key value pairs or a JSON or some other file containing multiple option keys and their new values?

1

WP CLI's option update command only accepts one key per call, but you can use other commands to handle updating multiple keys in sequence. The command page in the Codex has some examples.

# Update one option on multiple sites using xargs.
$ wp site list --field=url | xargs -n1 -I {} sh -c 'wp --url={} option update my_option my_value'

In this example, xargs is used to build commands based on input.

Depending on your data structure, you should be able to use xargs and some wp cli commands in combination to achieve the result you're looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.