<?php
   if ( ! defined( 'ABSPATH' ) ) {
     exit; // Exit if accessed directly
   }
?>

<?php get_header(); ?>
<?php $template_url = get_bloginfo ( 'template_url' ) . '/'; ?>
<?php 
   //to check if there is a post regarding the url access the page
   if (have_posts ()) :
     the_post(); 
   endif;
   
   $img = $template_url."img/acupuncturebg.jpg";
?>
<!-- breadcumb -->
<section class="z-index-common breadcumb-wrapper" style="background-image: url(<?php echo $img;?>); background-size: 100%;">
<div class="container">
  <div class="row justify-content-between align-items-center">
    <div class="col-auto">
      <div class="breadcumb-content">
        <h1 class="breadcumb-title">Blog Details</h1>
        <div class="breadcumb-menu-wrap">
          <ul class="breadcumb-menu">
            <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>">Home</a></li>
            <li>Blog Details</li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</div>
</section>
<section class="space space-extra-bottom blogpage">
    <div class="container">
      <div class="row">
        <div class="col-lg-8 col-md-12 col-12">
          <div class="vs-blog blog-single">
            <div class="blog-body">
              <div class="mainblogimg">
                <img src="<?php the_field('front_image');?>" alt="<?php echo get_the_title();?>" class="img w-100">
              </div>
<!--               <span class="blog-date"><?php// echo get_the_date( 'd' );?> <span><?php// echo get_the_date( 'M y' );?></span></span> -->
              <div class="blog-content">
<!--                 <div class="blog-meta">
                  <a href="blog.html" tabindex="0">Posted <span>Admin</span></a>
                </div> -->
                <h3 class="blog-title"><?php echo get_the_title();?></h3>
                <?php echo get_the_content();?>
              </div>
            </div>
          </div>
        </div>

        <div class="col-lg-4 col-md-12 col-12">
          <div class="sidebar-area">
            <div class="widget">
              <h3 class="widget_title">
                Recent Posts
              </h3>
              <div class="recent-post-wrap">
                <?php
                                    $args = array ( 
                                        'post_type'      => 'post',
                                        'post_status'    => 'publish', 
                                        'orderby' => 'publish_date',
                                        'order' => 'DESC',  
                                        'posts_per_page' => 5
                                    );
                                         $query = new WP_Query($args);
                                         $post_count = $query->post_count;
                                         if ( $query->have_posts() ){
                                           $i = 1;
                                         while ( $query->have_posts() ){
                                             $blog_img_url = get_the_post_thumbnail_url( get_the_ID(),'full');
                                             $query->the_post();
                                   ?>
                                   <div class="recent-post">
                                      <div class="media-img">
                                        <a href="<?php the_permalink();?>"><img src="<?php the_field('front_image');?>" alt="Blog Image"></a>
                                      </div>
                                      <div class="media-body">
                                        <h4 class="post-title">
                                          <a class="text-inherit" href="<?php the_permalink();?>">
                                            <?php echo get_the_title();?>
                                          </a>
                                        </h4>
                                      </div>
                                    </div>
                                    <?php
                                     $i++;
                                     }
                                   }wp_reset_postdata();
                                 ?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
<?php get_footer(); ?>