• Ced

    (@cedriccharles)


    Hi everybody !

    In a custom plugin, I use add_options, update_options and get_options to set and get different options.

    In WordPress Multisite, does it add and get options in a different database for each site or do I have to use an other function ?

    Thanks a lot 🙂 !

Viewing 7 replies - 1 through 7 (of 7 total)
  • Use the same function. Multsite still uses one db by default, and each blog’s options table is prefixed with a blog ID number. wp_16_options, for example.

    THe only multisite specific options would be global.

    Thread Starter Ced

    (@cedriccharles)

    Ok but if I use get_option(‘name’) in a plugin, will it be the same option in each site ? or can i change the value of the option for one site without changing in in another site ?

    Ok but if I use get_option(‘name’) in a plugin, will it be the same option in each site ?

    No, it won’t. You’re getting the $blogid right before that, correct?

    You could also use get_site_option() or update_site_option() if you need to set site-wide options.

    Thread Starter Ced

    (@cedriccharles)

    No, i do nothing else right now… Could you give me an example ?

    If you’re just writing a regular plugin for single WordPress, just write it according to the guidelines. It should still work in multisite if it is activated on a per site basis.

    @cedric – Here is a quick bit of code I use to hit every site and see what theme they are using:

    $blogs = $wpdb->get_results("SELECT blog_id, domain, path FROM wp_blogs");
      $i = 0;
      foreach($blogs as $blog)
      {
        $blogtemplate= get_blog_option($blog->blog_id, 'template');
        if($blogtemplate==$old_template)
        {
          echo "<p>BLOG <a href='http://" . $blog->domain . $blog->path ."'>http://".$blog->domain . $blog->path."</a> changing from <strong>$blogtemplate</strong> to <strong>$new_template</strong><br>";
          switch_to_blog($blog->blog_id);
          switch_theme($new_template, $new_template);
          echo "</p>";
          $i++;
        }
      }

    Does this help?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘add/update/get_options’ is closed to new replies.