<?php
/*
Template Name:Gallery-template
*/
?>
<?php get_header(); ?>
<div id="core" class="gallary template_page">
	<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
	$args = array(
	'post_type' => 'gallery',
	'posts_per_page' => '15',
	'paged' => $paged,
	);
	$count_posts = wp_count_posts( 'gallery' )->publish;
	$my_posts = new WP_Query( $args );?>
	<?php $total_pages = $my_posts->max_num_pages;  ?>
	<?php $pages   = ceil($total_pages / 15);
		   $min     = (($paged * 15) - 15) + 1;
		   $max  = ($min + 15) - 1;?>
	
<div class="inner-page-section"> 

 	<div class="container">	
				<div class="gallary_section">
                
                
                  	
					<h1 class="inner-heading-txt"><?php the_title();?></h1>
					<?php if ( $my_posts->have_posts() ) :
								?>
					<div class="gallary-posts">
						<?php while ( $my_posts->have_posts() ) : $my_posts->the_post() ?>
					      <div class="pic-section">
							  
								<a href="<?php the_permalink();?>">
						             <div class="post-thumb-wrapp">
			          					<?php $id = get_the_ID();?><?php the_post_thumbnail( 'thumbnail' );?>
								<?php //echo get_the_post_thumbnail($id,'full', array('410','240'));?>
			           				</div>
	             					<div class="blog_tite"><?php the_title(); ?></div>
            				    </a>

							</div>
						   <?php endwhile;
									 wp_reset_query();?>
									 	<?php $page_url	=  site_url();?>
								<div class="pagination-bx gallery-pagination">
									 
									<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(); ?>
