<?php get_header();?>

<div id="wrapper-content">
	<div id="main">
		
				<article>
					<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>		
				<div class="post-heading">
					<h1><?php the_title(); ?></h1>
					<aside>
					<span class="heading-author"><?php the_author(); ?></span> 
					<time><span class="heading-date"><?php the_time('y-m-d'); ?></span></time>
					<span class="heading-comments"><?php comments_number('0','1','%'); ?>评论</span>
					<div class="post-meta-cats"><strong>栏目</strong> <span class="meta-arrow">»</span> <?php the_category(', ') ?> </div>
					</aside>
				</div>
							
				<div class="post-entry">
                        <?php the_content(); ?> 
										
					<div class="clear"></div>
				</div>
				
								
				<div class="post-meta">
					 
					<div class="upnewleft"><strong>上一篇</strong> <span class="meta-arrow">»</span> <?php previous_post_link('%link') ?></div>
										
					 
					<div class="upnewright"><strong>下一篇</strong> <span class="meta-arrow">»</span> <?php next_post_link('%link') ?></div>
						
				</div>
				
				 
				
								
				<div class="homepage-widget">
					<div class="block full">
						
						<h3>Related <span class="arrows">»</span></h3>

							
															
<?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' => 4,
        'caller_get_posts' => 1
    );
query_posts($args);

if (have_posts()) :
    while (have_posts()) : the_post(); update_post_caches($posts); ?>
 <div class="related-item">
         <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" target="_blank">
                                    <?php if ( get_post_meta($post->ID, 'show', true) ) : ?>
                                        <?php $image = get_post_meta($post->ID, 'show', true); ?>
                                        <img src="<?php echo $image; ?>"width="134" height="88" 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="134" height="88" />
                                        <?php } ?>
                                        <?php endif; ?>
                                </a>
        <h2>
            <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </h2>
</div>
<?php endwhile; else : ?>
<a>暂无相关文章</a>
<?php endif; wp_reset_query(); } ?>
									
					</div>
				</div>
																
				<div id="comments">
				
				
                        <?php comments_template(); ?>
		            
                 				
				</div>
                    <?php endwhile; ?>
				
	</article>

	</div>

    <?php get_sidebar();?>
</div>

<?php get_footer();?>

