<?php $query = new WP_Query($args); ?>
<?php $index = 0; ?>
<?php if ($query->have_posts()) : ?>
    <div class="retheme-post-widget is-layout-flow">
        <?php while ($query->have_posts()) : $query->the_post(); ?>

            <div <?php post_class("rt-post is-style-small-list flex gap-30") ?>>
                <div class="rt-post__thumbnail-wrap is-layout-flow" style="flex-basis: 120px">
                    <figure class="rt-post__thumbnail rt-img" style="aspect-ratio:<?php echo esc_attr(rt_get_option('post_image_ratio', '3/2')) ?>;">
                        <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
                            <?php the_post_thumbnail('thumbnail');  ?>
                        </a>
                    </figure>
                </div>

                <div class="rt-post__body is-layout-flow flex-1">
                    <h4 class="rt-post__title has-x-small-font-size has-link-overlay line-clamp-3">
                        <a href="<?php the_permalink() ?>"><?php echo get_the_title() ?></a>
                    </h4>
                    <div class="rt-post-meta is-layout-flex has-xx-small-font-size has-meta-color mt-10 gap-10">

                        <span class="rt-post-meta__item rt-post-meta-date">
                            <span class="rt-icon">
                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clock" viewBox="0 0 16 16">
                                    <path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71z" />
                                    <path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0" />
                                </svg>
                            </span>
                            <?php echo get_the_date() ?>
                        </span>

                        <?php if (get_comments_number() >= 1 && ($args['option_orderby'] == 'most_commented' || $args['option_orderby'] == 'recent_comments')) : ?>
                            <span class="rt-post-meta__separator">•</span>
                            <span class="rt-post-meta__item rt-post-meta-comment">
                                <?php echo wp_sprintf(__('%s Comments', 'jelajah-text'), get_comments_number()) ?>
                            </span>
                        <?php endif ?>

                    </div>
                </div>
            </div>

        <?php endwhile; ?>
    </div>
    <?php wp_reset_postdata(); ?>
<?php else : ?>
    <p><?php _e('No posts found', 'jelajah-text'); ?></p>
<?php endif; ?>