<?php
get_header();
?>

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

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

                    endwhile;
                ?>
            </div>
		</div>

		<?php
			$args = array(
				'post_type' => 'kariera',
				'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 oferty</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();
