Skip to content

Instantly share code, notes, and snippets.

@vadimkantorov
Last active November 6, 2024 11:54
Show Gist options
  • Save vadimkantorov/f3ab7fa3170f7bc197eaee3d3b141da6 to your computer and use it in GitHub Desktop.
Save vadimkantorov/f3ab7fa3170f7bc197eaee3d3b141da6 to your computer and use it in GitHub Desktop.
Primer of batch-exporting and batch-importing options from WordPress using wp-cli
# https://github.com/wp-cli/entity-command/issues/512
# https://developer.wordpress.org/cli/commands/option/list/
# https://developer.wordpress.org/cli/commands/option/update/
# export options to a pretty-formatted JSON file
wp option list --format=json | jq '.' > wpoptionimpex.json
# [
# {
# "option_name": "name1",
# "option_value": "value1"
# },
# {
# "option_name": "name2",
# "option_value": "value2"
# }
# ]
# import options from a JSON file
jq -r '.[] | [ (.option_name | @json), (.option_value | @json) ] | @tsv' wpoptionimpex.json | xargs wp option update --format=json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment