<?php
/*
Template Name:News-template
*/
?>
<?php get_header(); ?>
<div id="core" class="container_alt page template_page">
	<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
	$args = array(
	'post_type' => 'post',
	'posts_per_page' => '9',
	'paged' => $paged,
	);
	$count_posts = wp_count_posts( 'news' )->publish;
	$my_posts = new WP_Query( $args );?>
	<?php $total_pages = $my_posts->max_num_pages;  ?>
	<?php $pages   = ceil($total_pages / 9);
		   $min     = (($paged * 9) - 9) + 1;
		   $max  = ($min + 9) - 1;?>
		   <!--div class="media results">
			   <?//php  echo "Showing ";
				//echo $min  ." - ".  $max ." of " .$count_posts ." results"; ?>
 </div-->
 <div class="inner-page-section"> 
 	<div class="container">
			<div class="media-news">	
				<h1 class="inner-heading-txt"><?php the_title();?></h1>
				<?php if ( $my_posts->have_posts() ) :
							?>
							<div class="media-posts">
								<?php while ( $my_posts->have_posts() ) : $my_posts->the_post() ?>
								<div  class="gal-col all">
									<div class="pic-section">
										<a class="read-more" href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'medium_large' );?></a>
									</div>
								   <div class="text-box">
										<a class="read-more" href="<?php the_permalink(); ?>"><h3 class="sub-heading"><?php echo get_the_title()?></h3></a>
										<div class="news_date"><?php echo get_the_date();?></div>
										<a class="read-more" href="<?php the_permalink(); ?>">Read More</a>							
									</div>
								</div>
								<?php endwhile;
								 wp_reset_query();?>
							<?php $page_url	=  site_url();?>
								<div class="pagination-bx">
								    <div class="pagination bottom">
                                      <?php $total_pages = $my_posts->max_num_pages;?>
                                       <?php if ($total_pages > 1){?>
											<a class="first page button" href="<?php echo get_pagenum_link(1)?>">&laquo;</a>
                                          <?php $current_page = max(1, get_query_var('paged'));
                                          $image_path	= get_bloginfo('template_url');
                                            echo paginate_links(array(
                                           'base' => get_pagenum_link(1) . '%_%',
                                            'format' => '/page/%#%',
                                            'current' => $current_page,
                                            'total' => $total_pages,
                                            'prev_text'    => __('<img src="'. $image_path.'/assets/images/arrow-right.svg"> Prev'),
	                                        'next_text'    => __('Next  <img src="'. $image_path.'/assets/images/arrow-right.svg">'),
                                            ));?>
                                              <a class="last page button" href="<?php echo get_pagenum_link($my_posts->max_num_pages);?>">&raquo;</a>
                                             <?php }   ?>
                                         
                                     </div>
                                 </div>    
				    </div>
				<?php endif ?>
				</div>
		</div>
 </div>
    </div>
  <div class="clearfix"></div>
 <?php get_footer(); ?>
