<?php 
/**
 * Trending news category page
**/ 
?>
<?php get_header(); ?>

<div id="main">
	<div id="primary">
		<div class="category-name">
			<h1>
				<?php echo get_option('tn_word_before_category'); ?>
				<?php single_cat_title(); ?>
			</h1>
		</div><!--category-name-->    
    
    
    <?php 
	$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
	$category_id = get_cat_id( single_cat_title("",false) );
	if($page == 1){
			query_posts(array( 'posts_per_page' => 1, 'cat' => $category_id)); if (have_posts()) : while (have_posts()) : the_post();
    		?>
            
			<div class="latest-category-post">
				<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>
				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
				<?php the_post_thumbnail('solo-slider-img');?>
				</a>
				<?php } ?>
				<div class="category-page-text-box">
					<div class="category-page-title"><h2><a href="<?php the_permalink() ?>">
						<?php the_title(); ?>
						</a></h2>
					</div><!--category-page-text-box-->
					<div class="category-page-info">
						<span class="category-page-excerpt">
							<?php  $tn_subtitle = get_post_meta(get_the_ID(), 'tn_sub_title', true); if(empty($tn_subtitle)) { echo excerpt(22); }  else { echo $tn_subtitle;}  ?>
						</span>								
					</div><!--category-page-info-->
				</div><!--category-page-text-box-->
			</div><!--latest-category-post-->
 
				<?php endwhile; endif; ?>
            
            
            
                <div class="big-category big-two-posts">
                    <ul class="featured-posts-category-big">
                        <?php query_posts(array( 'posts_per_page' => 2, 'offset' => 1, 'cat' => $category_id )); if (have_posts()) : while (have_posts()) : the_post(); ?>
                          <li>
                              <div class="big-featured-posts-image">
                                  <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>
                                  <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('feat-cat-thumb'); if ( 'video' == get_post_format() ): echo '<span class="play-icon-big"></span>'; endif; ?></a>
                                  <?php } ?>
                                  <div class="big-featured-posts-title-box">
                                      <div class="big-featured-posts-title">
                                          <h2><a href="<?php the_permalink() ?>" class="big-featured-posts-title"><?php the_title(); ?></a></h2>
                                      </div><!--big-featured-posts-title-->
                                  </div><!--big-featured-posts-title-box-->
                              </div><!--big-featured-posts-image-->
                                  <div class="big-featured-posts-content">
                                      <?php echo excerpt(20); ?>
                                  </div><!--big-featured-posts-content-->	
                                  <div class="post-date">
                                      <span class="bypostauthor"><?php the_author_posts_link(); ?></span>
                                      <span class="date"><?php echo get_the_date(); ?></span>
                                  </div><!--post-date-->				
                          </li>
                                <?php endwhile; endif; ?>
                    </ul>
                </div><!--big-category-->
	<?php }else{};?>
		<div class="category-posts">
			<ul class="newest-posts-category">
				<?php if($page == 1){$ppp = get_option( 'posts_per_page' ) - 3; query_posts(array( 'posts_per_page' => $ppp, 'offset' => 3, 'cat' => $category_id ));}            
				else{};
				if (have_posts()) : while (have_posts()) : the_post();
				 ?>
				<li>
					<div class="newest-posts-thumb">
						<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>
						<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
						<?php the_post_thumbnail('carousel-thumb'); ?>
						</a>
						<?php } ?>
					</div><!--newest-posts-thumb-->
                    <div class="newest-posts-text">
                    <span class="category-sidebar-news"><?php $category = get_the_category(); if($category[0]){echo '<a href="'.get_category_link($category[0]->term_id ).'">'.$category[0]->cat_name.'</a>';} ?></span>
                        <h2><a href="<?php the_permalink() ?>" class="newest-posts-title">
                            <?php the_title(); ?>
                            </a>
                        </h2>
                        <div class="newest-posts-content">
                            <?php echo excerpt(37); ?>
                        </div><!--newest-posts-content-->
                        <div class="newest-posts-date-posted">
                            <span class="bypostauthor">
                            <?php the_author_posts_link(); ?>
                            </span>
                            <span class="date">
                            <?php echo get_the_date(); ?>
                            </span>
                            <span class="views-count">
                                <?php echo get_views(get_the_ID()); ?>
                            </span>
                            <span class="comments-count">
                                <?php comments_number( '0', '1', '%' ); ?>
                            </span>
                        </div><!--newset-posts-date-posted-->
                    </div><!--newest-posts-text-->
				</li>
				<?php endwhile; endif; wp_reset_query(); ?>
			</ul>
		</div><!--category-posts-->
		<div class="pagination"> 
			<?php tn_pagination(); ?>
		</div><!--pagination-->
	</div><!--primary-->
	<?php get_sidebar('category'); ?>
</div><!--main-->
<?php get_footer(); ?>
