<?php
/**
 * Partial template for banner slider timeline.
 *
 * @package PureNote
 */

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

$purenote_banner_timeline_title = 'Trending'; 
$timeline_enable = true; 

$timeline_args = array(
    'posts_per_page'      => 4,
    'orderby'             => 'comment_count', 
    'order'               => 'DESC',
    'ignore_sticky_posts' => true,
    'post_status'         => 'publish',
);

if ($timeline_enable): ?>
    <div class="timeline-wrapper">
        <h2 class="timeline-title">
            <?php echo esc_html($purenote_banner_timeline_title); ?> 
        </h2>
        
        <?php
        $timeline_query = new WP_Query($timeline_args);

        if ($timeline_query->have_posts()) :
            while ($timeline_query->have_posts()) : $timeline_query->the_post(); ?>
                <div class="single-post-wrapper">
                    <div class="post-thumbnail-wrap">
                        <?php 
                        if (function_exists('purenote_post_thumbnail')) {
                            purenote_post_thumbnail('purenote-block-medium');
                        }
                        ?>
                    </div>
                    <div class="post-title-wrap">
                        <div class="post-cats-wrap">
                            <?php 
                            if (function_exists('purenote_the_post_categories_list')) {
                                purenote_the_post_categories_list(get_the_ID(), 1);
                            } 
                            ?>
                        </div>
                        <h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                        <div class="post-date">
                            <?php if (function_exists('purenote_posted_on')) {
                                purenote_posted_on();
                            } ?>
                        </div>
                    </div>
                </div>
            <?php endwhile;
            wp_reset_postdata();
        else: ?>
            <p class="no-posts-found"><?php esc_html_e('No trending posts found.', 'purenote'); ?></p>
        <?php endif; ?>
    </div><!-- timeline-wrapper -->
<?php endif; ?>
