<?php get_header(); ?>

<?php if ( is_home() || is_front_page() ) : ?>
	<?php get_template_part( 'template-parts/slider' ); ?>
<?php endif; ?>

<main class="site-main">
	<div class="container content-grid">
		<section class="content-area">

			<?php
			$kgv_featured_post_id = absint( get_theme_mod( 'kgv_featured_post_id' ) );
			?>

			<?php
			// Featured Beitrag oben anzeigen
			if ( ( is_home() || is_front_page() ) && $kgv_featured_post_id ) :
				$featured_post = get_post( $kgv_featured_post_id );

				if ( $featured_post && 'publish' === $featured_post->post_status ) :
					setup_postdata( $GLOBALS['post'] = $featured_post );
					get_template_part( 'template-parts/content', get_post_type() );
					wp_reset_postdata();
				endif;
			endif;
			?>

			<?php if ( have_posts() ) : ?>
				<?php while ( have_posts() ) : the_post(); ?>

					<?php if ( $kgv_featured_post_id && get_the_ID() === $kgv_featured_post_id ) : ?>
						<?php continue; ?>
					<?php endif; ?>

					<?php get_template_part( 'template-parts/content', get_post_type() ); ?>

				<?php endwhile; ?>

				<div class="pagination">
					<?php the_posts_pagination(); ?>
				</div>

			<?php else : ?>
				<?php get_template_part( 'template-parts/content', 'none' ); ?>
			<?php endif; ?>

		</section>

		<?php get_sidebar(); ?>
	</div>
</main>

<?php get_footer(); ?>