<?php if (have_posts()): while(have_posts()): the_post(); ?>
  
    <div class="container">
      <div class="row">
        <div class="col-lg-8">
          <!-- Blog Details Section -->
          <div id="blog-details" class="blog-details section">
            <div class="container">
                  <h2 class="title"><?php the_title(); ?></h2>

              <div class="meta-top">
                <ul>
                  <li class="d-flex align-items-center"><i class="bi bi-person"></i> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>">
    <?php
        $fname = get_the_author_meta('first_name'); 
        $lname = get_the_author_meta('last_name');
        echo $fname . ' ' . $lname;
    ?>
</a>
</li>
                  <li class="d-flex align-items-center"><i class="bi bi-clock"></i> <a href="#"><time datetime="<?php echo get_the_date('c'); ?>"><?php echo get_the_date(); ?></time></a></li>
                </ul>
              </div><!-- End meta top -->

              <div class="content">
                <?php the_content(); ?>
              </div><!-- End post content -->

              <div class="meta-bottom">
                <i class="bi bi-folder"></i>
                <ul class="cats">
                  <li><?php the_category(', '); ?></li>
                </ul>

                <i class="bi bi-tags"></i>
                <ul class="tags">
                  <?php the_tags('<li>', '</li><li>', '</li>'); ?>
                </ul>
              </div><!-- End meta bottom -->
            </div>
          </div><!-- /Blog Details Section -->

          <!-- Blog Author Section -->
          <section id="blog-author" class="blog-author section">
            <div class="container">
              <div class="author-container d-flex align-items-center">
                <img src="<?php echo get_avatar_url(get_the_author_meta('ID')); ?>" class="rounded-circle flex-shrink-0" alt="">
                <div>
                  <h4>
    <?php
        $fname = get_the_author_meta('first_name'); 
        $lname = get_the_author_meta('last_name');
        echo $fname . ' ' . $lname;
    ?></h4>
                  <div class="social-links">
                    <a href="https://twitter.com/<?php echo get_the_author_meta('twitter'); ?>"><i class="bi bi-twitter"></i></a>
                    <a href="https://facebook.com/<?php echo get_the_author_meta('facebook'); ?>"><i class="bi bi-facebook"></i></a>
                    <a href="https://instagram.com/<?php echo get_the_author_meta('instagram'); ?>"><i class="bi bi-instagram"></i></a>
                  </div>
                  <p><?php the_author_meta('description'); ?></p>
                </div>
              </div>
            </div>
          </section><!-- /Blog Author Section -->
        </div>

        <div class="col-lg-4 sidebar">
          <div class="widgets-container">
            <!-- Categories Widget -->
            <div class="categories-widget widget-item">
              <div class="blog-contact-box mt-2">
                <div class="blog-contact-header">
                  Contact Nzamba Kitonga Advocates LLP Today!
                </div>
                <p class="blog-contact-description">
                  You've come to the right place!
                </p>
                <button class="btn btn-primary blog-contact-button">
                  Free Consultation
                </button>
                <!-- <div class="row justify-content-center">
                  <div class="col-12 col-md-9 blog-contact-info">
                    <i class="fa fa-phone"></i> +254 732 751 661
                  </div>
                </div> -->
              </div>
            </div><!--/Categories Widget -->

            <!-- Recent Posts Widget -->
            <div class="recent-posts-widget widget-item">
              <h3 class="widget-title">Recent Posts</h3>
              <?php
              $recent_posts = new WP_Query(array(
                'posts_per_page' => 4,
                'post_status' => 'publish',
              ));
              while ($recent_posts->have_posts()) : $recent_posts->the_post(); ?>
                <div class="post-item">
                  <?php if (has_post_thumbnail()) : ?>
                    <img src="<?php the_post_thumbnail_url('thumbnail'); ?>" alt="" class="flex-shrink-0">
                  <?php endif; ?>
                  <div>
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    <time datetime="<?php echo get_the_date('c'); ?>"><?php echo get_the_date(); ?></time>
                  </div>
                </div><!-- End recent post item-->
              <?php endwhile; wp_reset_postdata(); ?>
            </div><!--/Recent Posts Widget -->
          </div>
        </div>
      </div>
    </div>
  </section>
<?php endwhile; else : ?>
  <p><?php esc_html_e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

<?php get_footer(); ?>
