• I have made a wordpress multisite example.com. Now I want to call the latest news from a.example.com ,b.example.c.example.com…… . to show at the example home page.
    the follow code can call the updated blogs like a.example.com ,b.example.com and so on.
    `
    <?php
    $blogs = get_last_updated();
    if( is_array( $blogs ) ) {
    ?>

    <?php
    }
    ?>

    How I can call the latest news from subdomains.

    Thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Use something different. The code above will just get a list of blogs.

    http://wordpress.org/extend/plugins/diamond-multisite-widgets/

    Thread Starter wind0717

    (@wind0717)

    Thank you Andrea_r
    I will try it !

    Thread Starter wind0717

    (@wind0717)

    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 &micro;</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

      }
      ?>

      `<?php
      $blogs = get_last_updated();
      if( is_array( $blogs ) ) {
      ?>

    <?php
    }
    ?>
    </div>

    <?php get_footer(); ?>

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help ,I want to call subdomain's latest news on home page.’ is closed to new replies.