Advertisement
Guest User

Recent Posts across WP Network

a guest
Aug 27th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.09 KB | None | 0 0
  1. global $wpdb;
  2.                     $prefix = 'ZkUy_';
  3.                     $limit = 3;
  4.                     $sitesquery = '
  5.                         SELECT blog_id
  6.                         FROM '.$prefix.'blogs';
  7.                     $sites = $wpdb->get_results( $sitesquery );
  8.                     foreach( $sites as $site ) {
  9.                        
  10.                         $posts_table = $prefix.$site->blog_id.'_posts';
  11.                        
  12.                         $posts_table = esc_sql( $posts_table );
  13.                         $blogs_table = esc_sql( $prefix . 'blogs' );
  14.                        
  15.                         $postsquery = '
  16.                             SELECT *
  17.                             FROM '.$posts_table.'
  18.                             WHERE post_type="post"
  19.                             AND post_status="publish"
  20.                             ORDER BY post_date DESC LIMIT 0, '.$limit;
  21.                            
  22.                         $postsquery = $wpdb->prepare($postsquery);
  23.                         $siteposts = $wpdb->get_results($postsquery);
  24.                         foreach( $siteposts as $post ) : setup_postdata($post); ?>
  25.                             <div id="post-<?php the_ID(); ?>" <?php post_class( array('row') ); ?>>
  26.                                 <div class="span1">
  27.                                     <div class="timestamp">
  28.                                         <span class="timestamp_year"><?php the_time('Y'); ?></span>
  29.                                         <span class="timestamp_bottom">
  30.                                             <span class="timestamp_month"><?php the_time('M'); ?></span>
  31.                                             <span class="timestamp_day"><?php the_time('j'); ?></span>
  32.                                         </span>
  33.                                     </div>
  34.                                     <div class="comments_number">
  35.                                         <?php $commentNo = get_comments_number();
  36.                                                 if( $commentNo == 0 ) { ?>
  37.                                                 <a href="<?php comments_link(); ?>" class="comments_number_link">Discuss!</a>
  38.                                                 <?php } else { ?>
  39.                                                 <a href="<?php comments_link(); ?>" class="comments_number_bubble"><?php echo $commentNo; ?></a>
  40.                                             <?php } ?>
  41.                                     </div>
  42.                                 </div>
  43.                                 <div class="span7">
  44.                                     <div class="post_content">
  45.                                         <h2 class="post_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  46.                                         <div class="postmeta_top">
  47.                                             <span class="post_author">by <?php the_author_link(); ?></span> &bull; <span class="post_category">posted in <?php the_category(', '); ?></span>
  48.                                         </div>
  49.                                         <div class="post_entry">
  50.                                             <?php the_post_thumbnail(); ?>
  51.                                             <?php the_content(); ?>
  52.                                         </div>
  53.                                     </div><!-- .post_content -->
  54.                                 </div>
  55.                             </div>
  56.                         <?php endforeach; wp_reset_postdata();
  57.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement