0

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?

1

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

| 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
0

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.

http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/ms-blogs.php

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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