I want to include more than one wp-blog-header.php like the following.

$config = array(
        "path" => "/path/to/blog/1/"
        "path" => "/path/to/blog/2/"

foreach($config as $site){
    echo get_site_url().' '.$site['path'].'<br>';

I get echo out the first site_url 2 times. So i believe there wordpress doesn't connect to second blog.

Is there a way to reset connection and everything which was included?

  • 1
    What problem are you trying to solve with this solution? This is almost certainly a dead end and a red herring – Tom J Nowell Jul 15 '19 at 9:55

This will never work, you cannot include wp-blog-header.php multiple times from different installs.

After you include the first blog header, all of the WP functions are now present in the global namespace, all the databse details set, plugins and theme loaded, etc. In order to reset things you would need an entirely new request, defeating the point.

If your goal is to gather data from multiple instances there are better solutions:

  • A multisite installation, allowing switch_to_blog() to do this
  • Calling the REST API ( this can be done via JS or even a different program written in a different language )
  • WP CLI commands

But loading the code of multiple WP installations at the same time is not a solution, and will never work

  • Yes I realized that. I am using the xmlrpc api now. Thanks – delueg Jul 15 '19 at 13:23

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.