<?php get_header(); ?>
<div class="clear"></div>
<div id="mainbg">
	<div class="center">
		<div id="main" class="lbg">
			<div id="bcrumbs">
				<a href="<?php bloginfo('home'); ?>" title="返回首页">首页</a>>>
				<?php the_category(multiple); ?>>>
				<a><?php the_title(); ?></a>
			</div>
		<!--文章循环-->
		<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
			<div id="single">
				<h2><?php the_title(); ?></h2>
				<span><?php the_author(); ?> 发表于<?php the_time('Y年m月d日') ?> - <?php comments_number('0','1','%'); ?>条评论 &nbsp;&nbsp;所属分类：<?php the_category(', ') ?>&nbsp;&nbsp;<?php edit_post_link( __('[编辑文章]')); ?><?php setPostViews(get_the_ID()); ?></span>
				
					<?php the_content(); ?>
				
			</div>
			<div class="postcopyright">
					<p><strong> 声明: </strong> 本文由(<a href="<?php bloginfo('home'); ?>"> <?php the_author(); ?> </a>)原创编译，转载请保留链接: <a href="<?php the_permalink()?>" title=<?php the_title(); ?>><?php the_title(); ?></a></p>
			</div>
		<?php endwhile; ?>
			<div class="postcopyright">
					<ul>
						<li class="first">上一篇：<?php previous_post_link('%link') ?> </li>
						<li class="last">下一篇：<?php next_post_link('%link') ?></li>
					</ul>
			</div>
		<!--文章循环结束-->
			<div id="love">
				<h3>猜你喜欢的文章</h3>
				<ul>
					<?php
					$cats = wp_get_post_categories($post->ID);
					if ($cats) {

					$cat = get_category( $cats[0] );
					$first_cat = $cat->cat_ID;
					$args = array(
					        'category__in' => array($first_cat),
					        'post__not_in' => array($post->ID),
					        'showposts' => 5,
					        'caller_get_posts' => 1
					    );
					query_posts($args);

					if (have_posts()) :
					    while (have_posts()) : the_post(); update_post_caches($posts); ?>
					<li><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
							<?php if ( get_post_meta($post->ID, 'show', true) ) : ?>
											<?php $image = get_post_meta($post->ID, 'show', true); ?>
											<img src="<?php echo $image; ?>"width="250" height="150" alt="<?php the_title(); ?>"/>
											<?php else: ?>
											<?php if (has_post_thumbnail()) { the_post_thumbnail('home-thumb' ,array( 'alt' => trim(strip_tags( $post->post_title )), 'title' => trim(strip_tags( $post->post_title )),'class' => 'home-thumb')); }
											else { ?>
												 <img src="<?php echo catch_first_image() ?>" alt="<?php the_title(); ?>" width="250" height="150" />
											<?php } ?>
							<?php endif; ?>

						<span><?php the_title(); ?></span></a></li>
					<?php endwhile; else : ?>
					<li>* 暂无相关文章</li>
					<?php endif; wp_reset_query(); } ?>					
				</ul>
		<div class="clear"></div>
			</div>
			<!--评论-->
			<?php if (comments_open()) comments_template( '', true ); ?>
		</div>
		<?php get_sidebar(a); ?>
	</div>
</div>
<div class="clear"></div>
<?php get_footer(); ?>