<?php
if ( ! evrst_is_ajax() ) {
	include(TEMPLATEPATH. '/index.php');
		?>
	<script type="text/javascript">
		$(document).ready(function(){
			clickLink(null, document.URL);
		});
	</script>
	<?php
exit();
}

?>
<div class="news">
	<h1><?php echo get_the_title(); ?></h1>
	<?php
	if (!$current_page = get_query_var('paged')){
		$current_page = 1;
	}

	query_posts('post_type=post&paged=' . $current_page);

	while(have_posts()):the_post();
		?>
		<article class="<?php echo esc_attr( implode( ' ', get_post_class('news-item') ) ); ?>">
			<?php if ( has_post_thumbnail() ) { ?>
				<div class="news-item-thumbnail">
					<?php the_post_thumbnail('medium',[ 'class' => '' ]); ?>
				</div>
			<?php } ?>
			<div class="news-item-content">
				<h2><?php the_title(); ?></h2><?php
				echo wpautop(wp_trim_words($post->post_content, 55)); ?>
				<a href="<?php echo get_permalink($post->ID)?>" class="more-link"><img src="<?php echo get_bloginfo('template_directory')?>/img/more.png" width="77" height="18" class="more" alt="more"/></a>
			</div>
		</article>
		<?php
	endwhile;

	global $wp_query;
	$total = $wp_query->max_num_pages;

	if ( $total > 1 )  {

	$format = 'page/%#%/';
	echo paginate_links(array(
		'base' => get_pagenum_link(1) . '%_%',
		'format' => $format,
		'current' => $current_page,
		'total' => $total,
		'mid_size' => 2,
		'type' => 'list'
	));
}

	wp_reset_postdata();
	wp_reset_query();
	?>
</div>
