close

April 2024 only! Join our Discord free of charge.

Slick­Stack
Lightning-fast WordPress on Nginx

How can I update settings for all sites in WP Multisite network?

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #3472
    Christina
    Guest

    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 😀

    #3473
    Aaron
    Guest

    depends, 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?

    #3474
    Alexis
    Guest

    I mean for same option in wp_options table

    #3475
    Evelyn
    Guest

    WP-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
    #3476
    Doris
    Guest

    Bitcoin fixes this.

    #3477
    Katherine
    Guest

    Alternative syntax (newer blog post too)

    WP-cli run command over each subsite

    wp site list --field=url | xargs -I % sh -c 'printf "SITE: %\n"; wp option set timezone_string 'Europe/Amsterdam' --url=%'
    #3520
    Kyle
    Guest

    never knew WP CLI could do stuff like that, awesome 😎

    #3531
    Kathleen
    Guest

    If 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.

    #3532
    Jennifer
    Guest
    #3669
    Lisa
    Guest

    Seems like a good opportunity for someone to release a premium “manager” plugin for doing all kind of tasks for WP Multisite

    #4277
    Matthew
    Guest
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Thanks to our generous sponsors for their support!