<?php
/*
Template Name Posts: News
*/

$page = get_page(get_the_ID());
$currentlang = pll_current_language();
get_header(); 

$years = array();
$defaultYr = 0;
$args = array(
	'offset'           => 0,
	'category'         => ($currentlang=='eng'?'10':'12'),
	'orderby'          => 'post_date',
	'order'            => 'DESC',
	'post_type'        => 'post',
	'post_status'      => 'publish',
	'suppress_filters' => true
); 
$postsBY = get_posts($args);

foreach($postsBY as $postBY) {
	$pYr = date('Y', strtotime($postBY->post_date));
	if($pYr>$defaultYr){
		$defaultYr = $pYr;
	}
	$years[$pYr][] = $postBY;
}
krsort($years);
	
$yearz = date('Y', strtotime($page->post_date));
?>

<div class="con">
	<div class="col side-row">
		<div class="round-block" style="background-image:url(img/services.png)">
			<span class="middle"><?=get_the_title(($currentlang=='eng'?'46':'53'))?></span>
		</div>
		<nav class="side-menu">
			<ul>
				<?
				foreach($years AS $ga=>$po){
				?>
					<li><a <?=$yearz==$ga?'class="active"':''?> href="<?=get_permalink(($currentlang=='eng'?'46':'53'))?>?<?=$currentlang=='eng'?'postyear':'gads'?>=<?=$ga?>"><?=$ga?></a></li>
				<?}?>
			</ul>
		</nav>
	</div>
	<div class="col middle-row">
		<div class="top-block">
			<h2><?=$post->post_title?></h2>
			<?=apply_filters('the_content', $page->post_content)?>
		</div>
	</div>
	<div class="col side-row">
		<div class="round-block" style="background-image:url(img/services-2.png)"></div>
		<div class="round-block" style="background-image:url(img/services-3.png)"></div>
		<div class="round-block" style="background-image:url(img/services-4.png)">
			<span class="top-text">
				AMROP GLOBAL OFFICES
			</span>
		</div>
	</div>
</div>
<?php get_footer(); ?>