<?php
/**
 * The template part for displaying the Latest Posts.
 * 
 * @package Newsxo
 * 
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {	exit; }


if (!function_exists('newsxo_news_ticker_section')) :

    function newsxo_news_ticker_section(){
            if (get_theme_mod( 'brk_news_enable', true )) { ?>
            <!-- bs-latest-news -->
            <div class="bs-latest-news">
                <?php $category = newsxo_get_option('select_flash_news_category');
                $slider_post_order_by = newsxo_get_option('slider_post_order_by');
                $breaking_news_title = newsxo_get_option('breaking_news_title');
                $all_posts = newsxo_get_posts(5, $category, $slider_post_order_by);
                $count = 1;
                if ((!empty($breaking_news_title))){ ?>
                <div class="bn_title">
                    <h5 class="title"><i class="fas fa-bolt"></i><?php if (!empty($breaking_news_title)){ echo '<span>'.$breaking_news_title.'</span>'; } ?></h5>
                </div>
                <?php } ?>
                <!-- bs-latest-news_slider -->
                <div class="bs-latest-news-slider swipe bs swiper-container">
                <div class="swiper-wrapper">
                    <?php if ($all_posts->have_posts()) :
                    while ($all_posts->have_posts()) : $all_posts->the_post(); ?>
                        <div class="swiper-slide">
                        <a href="<?php the_permalink(); ?>">
                            <span><?php the_title(); ?></span>
                        </a>
                        </div> 
                        <?php $count++;
                    endwhile;
                    endif;
                    wp_reset_postdata(); ?> 
                </div>
                <div class="bs-latest-news-nav">
                    <div class="swiper-button-next"></div>
                    <div class="swiper-button-prev"></div>
                </div>
                </div>
                <!-- // bs-latest-news_slider -->
            </div>
            <!-- bs-latest-news -->
            <?php
        }
    }
endif;
add_action('newsxo_action_news_ticker_section', 'newsxo_news_ticker_section', 5);
?>
<!--news ticker start-->
    <div class="bs-latest-ticker-news">
        <?php do_action('newsxo_action_news_ticker_section'); ?>
    </div>
<!--news ticker end-->