<?php get_header(); ?>


        <!--====== All Blog Section ======-->


    <main id="primary" class="site-main py-5">
    <div class="container">
        <div class="row justify-content-center">
            
            <div class="col-lg-9">
                <h1 class="mb-4 trending-title">Search Results for : <?php echo esc_html( get_search_query() ); ?></h1>

                <div class="row">
                    

                <?php
                    if(have_posts()):
                        while(have_posts()): the_post();
                ?>
                    <div class="col-md-4 mb-4">
                        <div class="card h-100 shadow-sm border-0">
                             <?php
                             if(has_post_thumbnail()): 
                                the_post_thumbnail('medium', [
                                    'class' => 'img-fluid card-img-top img-animation',
                                    'alt' => get_the_title(),
                                ]);
                            endif;
                            ?>
                            <div class="card-body ">
                                <span class="badge bg-danger text-decoration-none text-white mb-2"><?php the_category(', ')?></span>
                                <h5 class="card-title fw-bold"><a href="<?php the_permalink(); ?>" class="text-dark text-decoration-none"><?php the_title(); ?> </a></h5>
                               <p class="card-text text-muted small mb-2">
                                    <i class="bi bi-person me-1"></i>
                                    <?php echo esc_html__( 'By', 'mohi' ) . ' ' . esc_html( get_the_author() ); ?>
                                    &nbsp;|&nbsp;
                                    <a href="<?php the_permalink(); ?>" class="text-muted text-decoration-none">
                                        <i class="bi bi-calendar me-1"></i>
                                        <?php echo esc_html( get_the_date( 'd M, Y' ) ); ?>
                                    </a>
                                    
                                    <br>
                                    <a ><i class="bi bi-chat-left"></i></a>
                                    <?php comments_popup_link( esc_html__( 'Leave a comment', 'mohi' ), esc_html__( '1 Comment', 'mohi' ), esc_html__( '% Comments', 'mohi' ), 'comment-link'); ?>
                                </p>

                                <p class="card-text"> <?php echo esc_html( get_the_excerpt() ); ?></p>
                                <div class="card-footer m-auto bg-white border-0">
                                   <a href="<?php echo esc_url( get_permalink() ); ?>" class="btn text-decoration-none blog-btn">
                                        <?php esc_html_e( 'Read More →', 'mohi' ); ?>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                
                <?php 
                    endwhile; else:
                ?> 
                        <p><?php esc_html_e( 'Sorry, no posts matched your criteria.', 'mohi' ); ?></p>
                <?php
                    endif;
                ?>

                </div>
                
                <nav aria-label="Blog Page Navigation" class="mt-4 mb-5">
                    <?php 
                        the_posts_pagination(array(
                            'screen_reader_text' => ' ',
                            'prev_text' => esc_html__( 'Previous', 'mohi' ),
                            'next_text' => esc_html__( 'Next', 'mohi' )
                        ));
                     ?>
                 
                </nav>

            </div>
            
            <?php get_sidebar(); ?>
            
        </div>
    </div>
</main>


<?php get_footer(); ?>

