Use something different. The code above will just get a list of blogs.
http://wordpress.org/extend/plugins/diamond-multisite-widgets/
Thank you Andrea_r
I will try it !
The plugin diamond-multisite-widgets is very good.
But I want to direct call the latest posts from all the subdomains not use plugin, I read the codes of the diamond-multisite-widgets ,I am a beginner of PHP,please help me to improve the code so I can achieve my needs.
I write the follow codes on the default homepage(home.php),but it not worked.
<?php get_header(); ?>
<div id="content" class="widecolumn">
<h2>WordPress µ</h2>
<p>This is a <a href="http://mu.wordpress.org/">WordPress Mu</a> powered site.</p>
<p>You can: <ul><?php wp_register(); ?><li> <?php wp_loginout(); ?></li><li> <a href="wp-signup.php">Create a new blog</a></li><li> Edit this file at <code>wp-content/themes/home/home.php</code> with your favourite text editor and customize this screen.</li></ul></p>
<h3>The Latest News</h3>
<ul>
<strong>Site News</strong>
<?php
global $wpdb;
$table_prefix = $wpdb->base_prefix;
echo $table_prefix;
$sqlstr=”;
$bloglist=get_blog_list(0,’all’);
$sqlstr=”SELECT 1 as blog_id, id, post_date_gmt from “.$table_prefix .”posts where post_status = ‘publish’ and post_type = ‘post’ “;
$uni =”;
foreach($blog_list AS $blog){
echo $blog[‘blog_id’];
if($blog[‘blog_id’]!=1){
if($sqlstr!=”)
$uni=’union’;;
$sqlstr .= $uni . ” SELECT “.$blog[‘blog_id’].” as blog_id, id, post_date_gmt from “.$table_prefix .$blog[‘blog_id’].”_posts where post_status = ‘publish’ and post_type = ‘post’ “;
}
}
$limit=’100′;
$sqlstr .= “ORDER BY post_date_gmt desc “.$limit;
//echo $sqlstr;
$post_list =$wpdb->get_results($sqlstr,ARRAY_A);
if(is_array($post_list)){
?>
<?php foreach($post_list as $post){
$p = get_blog_post($post[“blog_id”], $post[“id”]);
?>
- <?php echo $p->post_title;?>
<?php
}
?>
<?php
}
?>
</div>
<?php get_footer(); ?>
Thank you!