<?php

/**
 * Template name: Nagrody gwiazdy prasa
 *
 * The template for displaying full width page
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Dotspice
 * @version 1.3.0
 */
?>

<?php
get_header();

$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

query_posts(array(
	'post_type' => 'galeria_nagrody',
	'order' => 'DESC',
	'orderby'   => 'DATE',
	'paged'          => $paged,
	'posts_per_page' => 6
));

$loop = 0;
?>
<?php while (have_posts()) : the_post(); ?>
	<div class="col-sm-12" data-aos="fade-up">
		<article id="post-<?php the_ID(); ?>" <?php post_class('blog-post col-flex'); ?>>
			<div class="container p-0">
				<?php
				if ($loop % 2 == 1) : echo '<div class="row flex-row-reverse">';
				else :
					echo '<div class="row">';
				endif;
				?>
				<div class="col-sm-12 col-md-6">
					<a class="blog-post__img__link" href="<?php the_permalink(); ?>">
						<?php
						if (has_post_thumbnail()) {
							the_post_thumbnail(array(1000, 600, 'bfi_thumb' => true), array('class' => 'blog-post__img'));
						} else {
							echo wp_get_attachment_image(18, array(500, 375, 'bfi_thumb' => true));
						}
						?>
					</a>
				</div>
				<div class="col-sm-12 col-md-6 d-flex align-items-center">
					<?php
					if ($loop % 2 == 1) : echo '<div class="blog-post__content text-end justify-content-end">';
					else :
						echo '<div class="blog-post__content">';
					endif;
					?>
					<div class="blog-post__date"><?php echo get_the_date( 'Y-m-d' ); ?></div>
					<h2 class="blog-post__h"><a class="blog-post__h__link" href="<?php echo get_the_permalink(); ?>"><?php the_title(); ?></a></h2>
					<div class="blog-post__text">
						<?php
						if (has_excerpt()) {
							echo get_the_excerpt();
						} else {
							echo wp_trim_words(get_the_content(), 14);
						}
						?>
					</div>
					<div class="blog-post__btn"><a class="button" href="<?php the_permalink(); ?>"><?php esc_html_e('Read more', 'dotspice'); ?></a></div>
				</div>
			</div>
	</div>
	</div>
	</article><!-- #post-<?php the_ID(); ?> -->
	</div>
	<?php $loop++; ?>
<?php endwhile; ?>
<div class="pagination">
			<?php
				echo paginate_links( array(
					'prev_text' => __('←'),
					'next_text' => __('→'),
				) ); ?>
		</div>
<?php get_footer(); ?>