I am trying to retrieve data from multiple client WordPress websites on a single php page. So I can monitor all these websites without going through each one.

I am able to display data from one single website. Like this, I am listing all plugin installed on one WordPress.

<?php
  require( './domain1/wp-blog-header.php' );
  if ( ! function_exists( 'get_plugins' ) ) {
    require_once ABSPATH . 'wp-admin/includes/plugin.php';
  }
  $plugins = get_plugins();
  echo '<h1> ' . get_bloginfo( 'name' ) . '</h1>';
  foreach ( $plugins as $plugin ) {
    echo $plugin['Name'] . '<br />';
  }
?>

This works fine as I want. But when I try to do this for multiple website, it does not work but shows data from first website multiple times.

<?php
  $websites = array( 'domain1', 'domain2', 'domain3', 'domain4', 'domain5', 'domain6' );
  foreach ( $websites as $website ) {
    $file = './' . $website . '/wp-blog-header.php';
    require( $file );
    if ( ! function_exists( 'get_plugins' ) ) {
      require_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    $plugins = get_plugins();
    echo '<h1> ' . get_bloginfo( 'name' ) . '</h1>';
    foreach ( $plugins as $plugin ) {
      echo $plugin['Name'] . '<br />';
    }
  }
?>

Why it’s only showing details from first domain only? What am I doing wrong?
Can someone help me with this.

Thanks.

Read more here: Unable to retrieve data from multiple WordPress websites on same server


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: