<?php
$banner_title        = get_theme_mod( 'news_revolution_main_banner_title', __( 'Main Banner', 'news-revolution' ) );
$banner_button       = get_theme_mod( 'news_revolution_main_banner_button_label', __( 'View All', 'news-revolution' ) );
$banner_button_url   = get_theme_mod( 'news_revolution_main_banner_button_link' );
$banner_content_type = get_theme_mod( 'news_revolution_main_banner_content_type', 'post' );
if ( 'category' === $banner_content_type ) {
	$banner_category   = get_theme_mod( 'news_revolution_main_banner_content_category' );
	$banner_button_url = ! empty( $banner_button_url ) ? $banner_button_url : get_category_link( $banner_category );
} else {
	$banner_button_url = ! empty( $banner_button_url ) ? $banner_button_url : '#';
}
?>
<div class="banner-main-part">
	<?php if ( ! empty( $banner_title || $banner_button ) ) { ?>
		<div class="title-heading">
			<h3 class="section-title">
				<?php echo esc_html( $banner_title ); ?>
			</h3>
			<span class="title-dash"></span>
			<?php if ( ! empty( $banner_button ) ) { ?>
				<a href="<?php echo esc_url( $banner_button_url ); ?>" class="view-all"><?php echo esc_html( $banner_button ); ?></a>
			<?php } ?>
		</div>
	<?php } ?>
	<div class="banner-main-part-wrapper">
		<div class="banner-headline-wrap banner-main-carousel slick-button ">
			<?php
			$banner_query = new WP_Query( $main_banner_args );
			if ( $banner_query->have_posts() ) {
				while ( $banner_query->have_posts() ) :
					$banner_query->the_post();
					?>
					<div class="blog-post-container tile-layout">
						<div class="blog-post-inner <?php echo esc_attr( has_post_thumbnail() ? '' : 'no-thumbnail' ); ?>">
							<?php if ( has_post_thumbnail() ) { ?>
								<div class="blog-post-image">
									<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'post-thumbnail' ); ?></a>
								</div>
							<?php } ?>
							<div class="blog-post-detail">
								<div class="post-categories">
									<?php news_revolution_categories_list( true ); ?>
								</div>
								<h2 class="entry-title">
									<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
								</h2>
								<p class="post-excerpt">
									<?php echo wp_kses_post( wp_trim_words( get_the_content(), 20 ) ); ?>
								</p>
								<div class="post-meta">
									<?php news_revolution_posted_by(); ?>
									<?php news_revolution_posted_on(); ?>
								</div>
							</div>
						</div>
					</div>
					<?php
				endwhile;
				wp_reset_postdata();
			}
			?>
		</div>
		<div class="adver-slider">
			<?php
			for ( $i = 1; $i <= 2; $i++ ) {
				$ads_image     = get_theme_mod( 'news_revolution_advertisement_image_' . $i );
				$ads_image_url = get_theme_mod( 'news_revolution_advertisement_image_url_' . $i );
				if ( ! empty( $ads_image ) ) :
					?>
					<a href="<?php echo esc_url( $ads_image_url ); ?>"><img src="<?php echo esc_url( $ads_image ); ?>" alt="<?php esc_attr_e( 'Advertisment Image', 'news-revolution' ); ?>"></a>
					<?php
				endif;
			}
			?>
		</div>

	</div>
</div>



