How can I update settings for all sites in WP Multisite network?
- This topic is empty.
-
AuthorPosts
-
ChristinaGuest
Is there any easy way in SlickStack to run a MySQL query or something to easily modify the settings of all child sites in the Multisite network? would be amazing 😀
AaronGuestdepends, what setting are you talking about? if about unique settings or values for each site it might require a human to manually modify it one-by-one?
AlexisGuestI mean for same option in
wp_options
tableEvelynGuestWP-CLI to the rescue!
Run a WP-CLI command one or more sites on WordPress multisite
wp site list --field=url | xargs -n1 -I % wp --url=% option update my_option my_value
DorisGuestBitcoin fixes this.
KatherineGuestAlternative syntax (newer blog post too)
wp site list --field=url | xargs -I % sh -c 'printf "SITE: %\n"; wp option set timezone_string 'Europe/Amsterdam' --url=%'
KyleGuestnever knew WP CLI could do stuff like that, awesome 😎
KathleenGuestIf you are trying to set an option value in
wp_options
with serialized data it’s not going to work using the syntax of the commands provided above.Instead this is what worked for me:
1. First, replace the option value network-wide to something easy:
wp site list --field=url | xargs -n1 -I % wp --url=% option update my_option lolcow
2. Then use string search/replace like this:
wp search-replace --network 'lolcow' 'a:1:{s:1:"ex_key";s:2:"account";s:3:"ex_value";s:4:"346345734";}' --all-tables
This works better cuz its meant for string replacement.
You can put
--dry-run
to test it first too.JenniferGuestLisaGuestSeems like a good opportunity for someone to release a premium “manager” plugin for doing all kind of tasks for WP Multisite
MatthewGuestrelated plugin?
-
AuthorPosts