<?php
/**
 * The template for displaying all single posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
 *
 * @package BRPP_prawo_podatki
 */

get_header();
?>

	<main id="primary" class="site-main page-single-post">
		<div class="box-1">
			<div class="container">
				<?php
					while ( have_posts() ) :
						the_post();

						get_template_part( 'template-parts/content', get_post_type() );

						if (true == false) {
							the_post_navigation(
								array(
									'prev_text' => '<span class="nav-subtitle">' . esc_html__( 'Previous:', 'brpp-prawo-podatki' ) . '</span> <span class="nav-title">%title</span>',
									'next_text' => '<span class="nav-subtitle">' . esc_html__( 'Next:', 'brpp-prawo-podatki' ) . '</span> <span class="nav-title">%title</span>',
								)
							);

							if ( comments_open() || get_comments_number() ) :
								comments_template();
							endif;
						}

					endwhile; // End of the loop.
				?>
			</div>
		</div>

		<?php
			$args = array(
				'post_type' => 'post',
				'posts_per_page' => 3,
				'orderby'        => 'date',
				'order'          => 'DESC',
				'post__not_in' => array(get_the_ID()),
			);
			$other_posts = new WP_Query($args);

			if ($other_posts->have_posts()) :
		?>

		<div class="box-2">
			<div class="container">
				<div class="row" box-title="Blog">
					<div class="box-head">
						<h2>Zobacz też inne wpisy</h2>

						<div class="other-posts">
							<?php
								while ($other_posts->have_posts()) : $other_posts->the_post();
									$image = get_the_post_thumbnail_url(get_the_ID(), 'medium');
									$title = get_the_title();
									$link  = get_permalink();

									get_template_part(
										'inc/template-article-card', null, [
											'image' => $image,
											'title' => $title,
											'link'  => $link
										]
									);
								endwhile;
								wp_reset_postdata();
							?>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php endif; ?>
	</main><!-- #main -->

<?php
get_sidebar();
get_footer();
