WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way I can access the wp_options table of all the child sites? I want to create a multisite plugin that can be setup at the network level and will populate the child site plugins with defaults that can then be overwritten by the each individual site. I'm aware that I could read/write from wp_sitemeta this way, but in my instance, it would make sense if I could access the other "local" tables. I could probably write a custom query using the WP query function, but I was wondering if there was a better way?

share|improve this question
up vote 1 down vote accepted

Try get_blog_option(). It does not use switch_to_blog(), and so introduces much less overhead. https://codex.wordpress.org/Function_Reference/get_blog_option

share|improve this answer
Is there a function for writing options, too? And is there a function for retrieving all ID's for all sites? – NightHawk Mar 29 '12 at 19:57
update_blog_option(). I don't think there's a WP function for getting all site ids. Try: global $wpdb; $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs" ) ); – Boone Gorges Mar 29 '12 at 20:48
Gotcha. Thanks for your help! – NightHawk Mar 29 '12 at 22:07

Try switch_to_blog and restore_current_blog.

Both functions are quite expensive, you may wish to implement only small parts of their functionality, like changing the prefix of $wpdb.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.