How can I update settings for all sites in WP Multisite network?
- This topic is empty.
-
AuthorPosts
-
December 22, 2022 at 8:19 am #3472ChristinaGuest
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 😀
December 22, 2022 at 8:25 am #3473AaronGuestdepends, 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?
December 22, 2022 at 8:25 am #3474AlexisGuestI mean for same option in
wp_options
tableDecember 22, 2022 at 8:29 am #3475EvelynGuestWP-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
December 22, 2022 at 8:30 am #3476DorisGuestBitcoin fixes this.
December 22, 2022 at 8:31 am #3477KatherineGuestAlternative 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=%'
December 27, 2022 at 5:24 am #3520KyleGuestnever knew WP CLI could do stuff like that, awesome 😎
December 27, 2022 at 10:13 am #3531KathleenGuestIf 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.December 27, 2022 at 10:20 am #3532JenniferGuestJanuary 6, 2023 at 4:07 pm #3669LisaGuestSeems like a good opportunity for someone to release a premium “manager” plugin for doing all kind of tasks for WP Multisite
February 21, 2023 at 6:14 pm #4277MatthewGuestrelated plugin?
-
AuthorPosts
- You must be logged in to reply to this topic.