<?php
get_header();


 $special_podcasts_title = get_field('title', 'special_podcasts');
 $special_podcasts_list = get_field('wybrane_podcasty', 'special_podcasts');

 if (is_array($special_podcasts_list)) {
    $special_podcasts_list = array_filter($special_podcasts_list);
}
?>

<main id="primary" class="site-main">
	<section class="box-1">
		<div class="container">
			<?php
				while ( have_posts() ) :
					the_post();
					get_template_part( 'template-parts/content-podcast', get_post_type() );
				endwhile;
			?>
		</div>
	</section>
	<?php if (!empty($special_podcasts_list)) : ?>
	<section class="box-2">
		<div class="box-bg">
			<img src="/wp-content/uploads/2025/10/artilce-bg-1.svg" alt="">
		</div>
		<div class="container">
			<div class="row">
				<div class="box-title">
					<h2><?php echo esc_html($special_podcasts_title); ?></h2>
				</div>

				<div class="podcasty-list">
					<?php foreach ($special_podcasts_list as $post_obj): ?>
						<?php
							$post_id = $post_obj->ID;

							get_template_part('inc/template-podcast-card', null, [
								'image' => get_the_post_thumbnail_url($post_id, 'medium_large'),
								'title' => get_the_title($post_id),
								'link'  => get_permalink($post_id),
								'acf'   => get_field('time', $post_id),
							]);
						?>
					<?php endforeach; ?>
				</div>
			</div>
		</div>
	</section>
	<?php endif; ?>
</main>
<?php
get_sidebar();
get_footer();
