I'm using a plugin on Site A that shows announcements. I would like to put the same plugin on a different site (Site B), and have it pull the data from Site A, so that both sites show the same announcements simultaneously, based on the data that was entered on Site A.

As I read the code in the plugin, I see that they are using this line to get data from the DB:

$options = get_option( 'announcer_data' );

I could go to Site B and change the plugin code and make a mySQL call like this (using credentials for Site A):

$query = "SELECT option_value FROM wp_options WHERE option_name = 'name' ";

But that returns a very complicated string, as you might know (a:20:{s:7... etc.). So you see, get_option() on Site A's plugin returns a nice array, while my $query at Site B to Site A's server only pulls a complicated string.

I wish I could re-write the plugin on Site B so that it will fetch the get_option() array from Site A. But I don't know how to do this cleanly. I looked a serialize()/unserialize(), but I don't think those are the right methods to convert my $query string into the array with the proper format that get_option() creates.

Is there a way to call the get_option() method to get data from a different server? Do I need to somehow temporarily change the $wpdb global, and if so, how? I've researched this for a good amount of time, but I can't seem to find anything on Google or SE that addresses this. I'd rather not use multisite.

  • Are you currently running Site A and Site B as a multisite or do you have 2 independent sites that are not connected by anything more than the fact that you have db credentials to both?
    – bswatson
    Dec 20, 2016 at 19:10
  • @bswatson Hi, no, I do not have multisite. I only have the db credentials for both sites.
    – Mark
    Dec 20, 2016 at 19:16
  • To do it cleanly, you'll either need to use WP API or set up a remote call using wp_ajax_no_priv_{action} to make a request to the remote system to get the option. In order to save the request time when you actually need the value, you could hook into the option save on Site A to push the value to Site B (have Site B listen instead of request), and keep them in sync that way. You wouldn't have to modify the original plugin (if it isn't custom), and instead create your own custom plugin that handles this work as an add-on to the original.
    – bswatson
    Dec 20, 2016 at 19:32

1 Answer 1


You can use this function: get_blog_option https://codex.wordpress.org/Function_Reference/get_blog_option

Use get_sites function to retrieve blogs ID from your site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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