<?php
/**
 * Template part for displaying results in search pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Glowify WP
 */
$idd = get_the_ID();
$show_author_name = glowify_wp_option('archive_show_author_name');
$show_post_date = glowify_wp_option('archive_show_post_date');
$show_post_cat = glowify_wp_option('archive_show_post_cat');
$featured_img_url = get_the_post_thumbnail_url($post->ID, 'glowify-blog-thumb-grid');

?>

<div class="col-lg-6 col-md-6 col-12 blog-single-column grid-item">
	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

        <div class="cs_post cs_style_2 cs_type_1 cs_radius_8">
            <?php if (has_post_thumbnail()) : ?>
            <a href="<?php the_permalink(); ?>" class="cs_post_thumb cs_bg_filed cs_radius_8">
                <img src="<?php echo esc_url($featured_img_url); ?>" alt="<?php esc_attr_e('Thumbnail Not Found', 'glowify-wp'); ?>">
            </a>
            <?php endif; ?>
            <div class="cs_post_info">
                <?php if ($show_post_cat && !empty(get_the_category())) : ?>
                <div class="cs_post_category text-uppercase cs_light cs_accent_bg cs_white_color">
                    <?php 
                    // Display categories with links, separated by commas
                    the_category(', '); 
                    ?>
                </div>
                <?php endif; ?>
                <div class="cs_post_meta cs_light cs_primary_color">
                <?php if ($show_author_name) : ?>
                <a href="<?php echo get_author_posts_url(get_the_author_meta('ID'));?>">
                <span>                      
                    <?php the_author(); ?>       
                </span>
                </a>
                <?php endif; ?>
                <?php if ($show_post_date) : ?>
                <span>
                    <?php echo get_the_date(); ?>   
                </span>
                <?php endif;?>
                </div>
                <h2 class="cs_post_title cs_fs_24 cs_medium cs_secondary_font"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <p class="cs_post_subtitle cs_mb_16"><?php echo wp_trim_words(get_the_excerpt(), 22, '...'); ?></p>
            </div>
        </div>
	</article> <!-- #post-<?php the_ID(); ?> -->
</div>
