<?php 
get_header();
$options = get_option( 'kaveh_frame' );
if(!empty($options['kaveh_bl_cart_select'])){
$mkblogcart = $options['kaveh_bl_cart_select'];
}
if(!empty($options['blog-pic-repeater'])){
$blogslider = $options['blog-pic-repeater'];
}
?>

  <!-- Start Blog -->
  <div class="blog mt-4">
      <div class="container">
      <?php if(function_exists('get_breadcrumb')){get_breadcrumb();}?>
        <!-- Start Slider -->
        <div class="swiper swiper-blog position-relative">
          <div class="swiper-wrapper">
            <?php
            if(!empty($options['blog-pic-repeater'])){
            for ($i = 0; $i < count($blogslider); $i++) {
                ?>
              <div class="swiper-slide">
                <a href="#">
                  <img src="<?php echo $blogslider[$i]['blog-pic']; ?>" alt="article" class="d-block w-100" />
                </a>
               </div>
                <?php
            }
            }
            ?>
          </div>
          <div class="swiper-pagination d-none d-md-block"></div>
          <div class="swiper-button-next d-none d-md-block"></div>
          <div class="swiper-button-prev d-none d-md-block"></div>
        </div>
        <!-- End Slider -->
        <!-- Start Articles -->
        <button type="button" class="btn manblog category-btn-filter mb-4">
          <i class="icon-filter"></i>
          فیلتر بلاگ
        </button>
        <aside class="category-sidebar">
            <div class="category-sidebar-backdrop"></div>
            <div class="category-sidebar-content">
            <?php get_sidebar('blog') ?>
        </aside>
        <div class="row">

        <?php 
          if ( have_posts() ) {
          while ( have_posts() ) {
          the_post(); 
        if(!empty($options['kaveh_bl_cart_select'])){
        ?>
         <div class="col-lg-6 mb-4">
            <?php 
              switch ($mkblogcart):
              case "value-1":
                get_template_part("template-part/blog-cart-one");
                break; 
              case "value-2":
                get_template_part("template-part/blog-cart-two"); 
                break;
              case "value-3":
                get_template_part("template-part/blog-cart-three");
                break;
              case "value-4":
                get_template_part("template-part/blog-cart-four"); 
                break;
              case "value-5":
                get_template_part("template-part/blog-cart-five");
                break;
              case "value-6":
                get_template_part("template-part/blog-cart-six");
                break;
              case "value-7":
                get_template_part("template-part/blog-cart-seven"); 
                break;
              case "value-8":
                get_template_part("template-part/blog-cart-eight");
                break;
              case "value-9":
                get_template_part("template-part/blog-cart-nine"); 
                break;
              endswitch;	
              ?>   
          </div>

          <?php } 
            } // end while
          } // end if
          ?>
        </div>
        <!-- End Articles -->
        <!-- Start Pagination -->

        <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
        $total_post_count = wp_count_posts();
        $published_post_count = $total_post_count->publish;
        $total_pages = ceil( $published_post_count / $posts_per_page );  
        ?>  

        <ul class="pagination justify-content-center mt-5">
          <li class="page-item">
            <a href="<?php echo get_previous_posts_page_link(); ?>" class="page-prev"> قبلی </a>
          </li>
          <li class="page-item">
          
            <?php for( $paged = 1; $paged <= $total_pages; $paged++) : ?>
            <a href="<?php echo esc_url( get_pagenum_link( $paged ) ) ?>"><span class="now"> <?php echo esc_html($paged); ?>  </span></a>
            <?php endfor; ?>
          </li>
        
          <li class="page-item">
            <a href="<?php echo get_next_posts_page_link(); ?>" class="page-next"> بعدی </a>
          </li>
        </ul>
        <!-- End Pagination -->
      </div>
    </div>
    <!-- End Blog -->



<?php 
get_footer();
?>