<?php 
/**
 * Posts Layout 4 for SKT Education Lite
 *
 * Displays The Posts in Layout 4 
 *
 * @package SKT Education Lite
 * 
 * @since SKT Education Lite 1.0
 */
global $complete;?>
<?php
$post_type = get_post_type();
if($post_type=='gallery'){ ?>
	<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' => '20',
	'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 / 20);
		   $min     = (($paged * 20) - 20) + 1;
		   $max  = ($min + 20) - 1;?>
	
<div class="inner-page-section"> 

 	<div class="container">	
				<div class="gallary_section">
                
                
                  	
					<h1 class="inner-heading-txt"><?php echo "Gallery"//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	$featured_img_url = get_the_post_thumbnail_url($id, 'thumbnail');
								 //echo get_the_post_thumbnail($id,'thumbnail', array('300brbtr','300'));?>
								 <img src="<?php echo $featured_img_url;?>" style="max-width:296px;max-height:304px;">
			           				</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	
}
else{?>
    <div class="lay4">
        <div class="center">
            <div class="lay4_wrap">
                <div class="lay4_inner">
					<?php if(have_posts()): ?><?php while(have_posts()): ?><?php the_post(); ?>
                    <div <?php post_class(); ?> id="post-<?php the_ID(); ?>"> 

                <!--POST THUMBNAIL START-->
                        <div class="post_image">
                             <!--CALL TO POST IMAGE-->
                            <?php if ( has_post_thumbnail() ) : ?>
                            <div class="imgwrap">
                            <a href="<?php the_permalink();?>"><?php the_post_thumbnail('medium'); ?></a></div>

                          <?php elseif(!complete_gallery_thumb() == ''): ?>
                          <div class="imgwrap">
							<div class="icon_wrap animated fadeInUp">
                              		<div class="blog_mo"><a href="<?php the_permalink();?>">+ Read More</a></div>
                            </div>
                          <a href="<?php the_permalink();?>"><img src="<?php echo complete_gallery_thumb();?>" alt="<?php the_title_attribute(); ?>" class="thn_thumbnail"/></a></div>

                            <?php elseif(!complete_first_image() == ''): ?>
            
                            <div class="imgwrap">
                            <a href="<?php the_permalink();?>"><img alt="<?php the_title(); ?>" src="<?php echo complete_first_image(); ?>" /></a></div>
                          
                          <?php else : ?>
                            
                            <div class="imgwrap">
                            <a href="<?php the_permalink();?>"><img src="<?php echo complete_placeholder_image();?>" alt="<?php the_title_attribute(); ?>" class="complete_thumbnail"/></a></div>   
                                     
                            <?php endif; ?>
                        </div>
                 <!--POST THUMBNAIL END-->

                    <!--POST CONTENT START-->
                        <div class="post_content">
                            <h2 class="postitle"><a href="<?php the_permalink();?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                            
                         <!--META INFO START-->   
 
                            <div class="single_metainfo">
                            	<!--DATE-->
                                <i class="fa-calendar"></i><a class="comm_date"><?php the_time( get_option('date_format') ); ?></a>
                                <!--AUTHOR-->
                                <i class="fa-user"></i><?php global $authordata; $post_author = "<a class='auth_meta' href=\"".get_author_posts_url( $authordata->ID, $authordata->user_nicename )."\">".get_the_author()."</a>\r\n"; echo $post_author; ?>
                                <!--COMMENTS COUNT-->
                                <i class="fa-comments"></i><?php if (!empty($post->post_password)) { ?>
                            <?php } else { ?><div class="meta_comm"><?php comments_popup_link( __('0 Comment', 'complete'), __('1 Comment', 'complete'), __('% Comments', 'complete'), '', __('Off' , 'complete')); ?></div><?php } ?>
                            	<!--CATEGORY-->
                              	<i class="fa-th-list"></i><div class="catag_list"><?php the_category(', '); ?></div>
                            </div>
                            
                         <!--META INFO START-->  
                         
                            <?php complete_excerpt('complete_excerptlength_teaser', 'complete_excerptmore'); ?>
                            
                        </div>
                    <!--POST CONTENT END-->
					<!--Read More Button-->
                    <div class="blog_mo"><a href="<?php the_permalink();?>">+ Read More</a></div>
                    
                </div>
                <?php endwhile ?> 
    
                <?php endif ?>
                </div><!--lay4_inner class END-->
                
        <!--PAGINATION START-->
            <div class="ast_pagenav">
					<?php the_posts_pagination( array('mid_size' => 2,'prev_text' => '','next_text' => '','screen_reader_text ' => '') );  ?>
            </div>
        <!--PAGINATION END-->
            
            <?php wp_reset_postdata(); ?>
            
            </div><!--lay4_wrap class END-->
                    
                <!--SIDEBAR START-->    
            		<?php get_sidebar();?>
            	<!--SIDEBAR END--> 
                
            </div><!--center class END-->
        </div><!--lay4 class END-->

<?php } ?>
