<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package prime-fitness-gym
 */

?>
<div class="maincontent">
    <div class="post-item">
        <div class="row">            
            <div class="col-xl-12 col-lg-12 col-md-12 col-12">
                <div class="meta-para mt-4">
                    <div class="entry-meta d-flex">
                        <div>
                            <h4 class="post-date">
                                <i class="fa-regular fa-calendar-days me-2"></i> <a
                                    href="<?php the_permalink();?>"><?php echo esc_html(get_the_date('d M Y')); ?></a>
                            </h4>
                        </div>

                        <div class="post-comment">
                            <i class="fa-regular fa-comment me-2"></i><a href="javascript:void(0);" class="">
                                (<?php echo esc_html(get_comments_number()); ?>) </a>
                        </div>

                    </div><!-- .entry-meta -->
                    <div class="entry-container">
                        <header class="pb-3">
                            <h2 class="page-title mb-0">
                                <?php
                        // Wrap the post title in an anchor tag linking to the post
                        echo '<a href="' . esc_url(get_permalink()) . '">' . esc_html(get_the_title()) . '</a>';
                        ?>
                            </h2>
                            <div class="post-details mt-2">
                                <?php $prime_fitness_gym_author = get_theme_mod('prime_fitness_gym_post_hide_author',false);
					        if($prime_fitness_gym_author === false){ ?>
                                <span
                                    class="me-2 entry-by"><?php echo esc_html(get_theme_mod('prime_fitness_gym_meta_field_by', '- By'));?></span><span
                                    class="entry-author"><a
                                        href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' )) ); ?>"><?php the_author(); ?><span
                                            class="screen-reader-text"><?php the_author(); ?></span></a></span>
                                <?php } ?>

                                <?php $prime_fitness_gym_time = get_theme_mod('prime_fitness_gym_post_hide_time',false);
				            if($prime_fitness_gym_time === false){ ?>
                                <span
                                    class="mx-2"><?php echo esc_html(get_theme_mod('prime_fitness_gym_meta_field_separator', '|'));?></span><span
                                    class="entry-time"><?php echo esc_html( get_the_time() ); ?></span>
                                <?php } ?>
                            </div>
                        </header>
                        <!-- </?php the_content(); ?> -->
                        <p><?php
                        // Set a word limit, e.g., 40 words
                        $prime_fitness_gym_content_limit = 20; 

                        // Get the content and trim it
                        echo wp_trim_words(get_the_content(), $prime_fitness_gym_content_limit, '');
                        
		            ?></p>

                        <?php
                        // Optionally add a 'Read More' link
                        echo '<a class="readbtn" href="' . get_permalink() . '">' . __('Read More',
                            'prime-fitness-gym') . '</a>';
                            ?>
                    </div>
                </div>

            </div>
        </div>



    </div>

</div>