<?php
/**
 * Template part for displaying posts in a grid
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package eco-solar-energy
 */

$eco_solar_energy_archive_year  = get_the_time('Y');
$eco_solar_energy_archive_month = get_the_time('m');
$eco_solar_energy_archive_day   = get_the_time('d');
$separator = esc_html( get_theme_mod('eco_solar_energy_meta_field_separator', '|') );
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <div class="post-grid-item mb-4">
        <div class="main-box-post">            

            <!-- Post Meta -->
            <header class="entry-header">
                <?php $eco_solar_energy_date = get_theme_mod('eco_solar_energy_post_hide_date', false);
                if ($eco_solar_energy_date === false) { ?>
                    <span class="entry-date">
                        <a href="<?php echo esc_url(get_day_link($eco_solar_energy_archive_year, $eco_solar_energy_archive_month, $eco_solar_energy_archive_day)); ?>">
                            <?php echo esc_html(get_the_date()); ?>
                        </a>
                    </span>
                <?php } ?>

                <div class="post-info">
                    <?php $eco_solar_energy_author = get_theme_mod('eco_solar_energy_post_hide_author', false);
                    if ($eco_solar_energy_author === false) { ?>
                        <span class="entry-sep"></span>
                        <span class="entry-author"><i class="fa fa-calendar" aria-hidden="true"></i>
                            <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>">
                                <?php the_author(); ?>
                            </a>
                        </span>
                    <?php } ?>

                    <?php $eco_solar_energy_comment = get_theme_mod('eco_solar_energy_post_comments', false);
                    if ($eco_solar_energy_comment === false) { ?>
                        <span class="entry-sep"></span>
                        <span class="entry-comments"><i class="fa fa-comment" aria-hidden="true"></i>
                            <?php comments_number(__('0 Comment', 'eco-solar-energy'), __('1 Comment', 'eco-solar-energy'), __('% Comments', 'eco-solar-energy')); ?>
                        </span>
                    <?php } ?>

                    <!-- </?php $eco_solar_energy_time = get_theme_mod('eco_solar_energy_post_hide_time', false);
                    if ($eco_solar_energy_time === false) { ?>
                        <span class="entry-sep"></span>
                        <span class="entry-time"></?php echo esc_html(get_the_time()); ?></span>
                    </?php } ?> -->
                </div>
            </header>

            <!-- Title & Content -->
            <div class="entry-content">
                <?php
                if (is_singular()):
                    the_title('<h1 class="entry-title">', '</h1>');
                else:
                    the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>');
                endif;

                // if (has_excerpt()) {
                //     the_excerpt();
                // } else {
                //     echo wp_trim_words(get_the_content(), 20, '...');
                // }
                ?>

                <a class="readbtn " href="<?php the_permalink(); ?>">
                    <?php _e('Read More....', 'eco-solar-energy'); ?>
                </a>
            </div>
        </div>
    </div>
</article>
