<?php
/**
 * Template part for displaying news ticker
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Covfefe
 */

?>
<div class="covf-news-ticker">
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<div class="covf-news-ticker-container">
					<ul class='marquee' data-duration='20000' data-gap='30' data-duplicated='true' >
						<?php
							$ticker_args = array();
							$ticker_post_count = 6;
							$ticker_tags = get_theme_mod( 'ticker_tags' );
							if (!empty($ticker_tags)) {
								$tag_slugs = explode(',', $ticker_tags);
								$tag_slugs = array_map('trim', $tag_slugs);
								$ticker_args['tag_slug__in'] = $tag_slugs;
							}
		
							$ticker_args['ignore_sticky_posts'] = 1;
							$ticker_args['posts_per_page'] = $ticker_post_count;
							
							$ticker_query = new WP_Query( $ticker_args );
							if( $ticker_query->have_posts() ) {
								
								while( $ticker_query->have_posts() ) {
									$ticker_query->the_post();
						?>			
									<li class="news-ticker-title">
										<?php echo wp_kses_post(covfefe_post_format_icon()); ?>	<a href="<?php the_permalink(); ?>"><?php the_title();?></a> 
									</li>
						<?php
								}
								
							}
							wp_reset_postdata();
						?>
					</ul>
					<div class="marquee-headline">
						<?php echo esc_html__( 'BREAKING NEWS' , 'covfefe' ); ?>
					</div>
					<div class="marquee-right">
						
					</div>
				</div>
			</div>
		</div>
	</div>
</div>