<div class="relates">
  <div class="title" style="margin-bottom:30px; margin-top:20px;">
    <h3>相关推荐</h3>
  </div>
</div>
<div class="clearfix relate-boxx">
  <ul class="clearfix list">
  <?php
$post_num = 6;
$exclude_id = $post->ID; 
$posttags = get_the_tags(); $i = 0;

if ( $i < $post_num ) { 
	$cats = ''; foreach ( get_the_category() as $cat ) $cats .= $cat->cat_ID . ',';
	$args = array(
		'category__in' => explode(',', $cats), 
		'post__not_in' => explode(',', $exclude_id),
		'caller_get_posts' => 1,
		'orderby' => 'comment_date',
		'posts_per_page' => $post_num - $i
	);
	query_posts($args);
	while( have_posts() ) { the_post(); ?>
    <li> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" target="_blank">
      <div class="overlay"></div>
     <img alt="<?php the_title_attribute(); ?>" title="<?php the_title_attribute(); ?>" src="<?php echo get_template_directory_uri(); ?>/timthumb.php?src=<?php echo post_thumbnail_src(); ?>&h=150&w=260&zc=1" > 
      <!-- Lazy加载动画图片换成cdn地址 by BeckMint-->
      <div class="titlee"><?php the_title(); ?></div>
      </a> </li>
      
      	<?php $i++;
	} wp_reset_query();
}
if ( $i  == 0 )  echo '<div class=\"r_title\">没有相关文章!</div>';
?>
  </ul>
</div>
