The MU forums have moved to WordPress.org

Anyone know to display blog id? I know how to do author= (2 posts)

  1. iwillpayou
    Member
    Posted 14 years ago #

    ok what i am trying to do is get certain storys showing up from different blogs from the same site... I know how to get all the storys show up from the main page but not the others. I have tried many things and keep getting stuck.. is there a certain way to display the blogs?

    ex
    <?php query_posts('author=2&showposts=4'); ?>

    Say if i don't want to pull in from the author but i want to pull in from the blog... a big reward if anyone can help me solve it.

  2. r@keshD
    Member
    Posted 13 years ago #

    You can use this code:

    <?php
    $domain = $wpdb->get_var( "SELECT domain FROM {$wpdb->blogs} WHERE blog_id=".$wpdb->blogid);
    
    $posts = $wpdb->get_col( "SELECT ID FROM wp_".$wpdb->blogid."_posts WHERE guid like '%".$domain."%'");
    foreach($posts as $p)
    {
    $postdetail=get_blog_post($wpdb->blogid,$p);
    ?>
    <a href="<?php echo $postdetail->guid;?>"><?php echo $postdetail->post_title;?></a>;
    
    <?php
    }
    ?>

    Above code shows current blog's posts,you can use any blog id to show posts of that blog in place of '$wpdb->blogid'.

    Hope,it'll help you..

About this Topic

  • Started 14 years ago by iwillpayou
  • Latest reply from r@keshD