<?php
/**
 * Template Name: Blog Page with Left Sidebar Template
 *
 * @package peccular Premium
 */
get_header(); ?>
  <?php $image = wp_get_attachment_url( get_post_thumbnail_id($post->ID));?>
<div class="peccular-page-main"> 
   <header class="page-main-header2" 
  <?php
    if(get_theme_mod('innerpage_featured_img_on_off') != 'on' ){
  ?>

 <?php  if (!empty($image)) : ?>
  style="background: url('<?php echo esc_url($image); ?>'); background-repeat: no-repeat; background-size:cover;background-position: center;  height: <?php echo esc_attr(get_theme_mod('peccular_innerpage_image_height','416')) ?>px;
  "
  <?php endif ?> 

 <?php } ?>

  >
   <?php  
         echo '<img alt="about us" src="'.get_template_directory_uri().'/images/triangledot.png" class="triangle" />';
  ?> 
  <?php  
      echo '<img alt="about us" src="'.get_template_directory_uri().'/images/circledot.png" class="circledot" />';
  ?>
<?php
    if(get_theme_mod('page_title_on_off') != 'on' ){
  ?>
    <div class="<?php if(get_theme_mod('peccular_inner_page_width','Box Width') == 'Box Width'){ ?>container <?php } elseif(get_theme_mod('peccular_inner_page_width','Box Width') == 'Full Width'){ ?> container-fluid <?php }?> <?php echo esc_attr(get_theme_mod('peccular_innerpage_header_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="1s">
        <?php the_title( '<h1 class="ht-main-title">', '</h1>' ); ?>
        <div class="clearfix"></div>
    </div>
 <?php } ?> 
 <?php
    if(get_theme_mod('breadcrumb_on_off') != 'on' ){
  ?>
        
            <div class="<?php if(get_theme_mod('peccular_inner_page_width','Box Width') == 'Box Width'){ ?>container <?php } elseif(get_theme_mod('peccular_inner_page_width','Box Width') == 'Full Width'){ ?> container-fluid <?php }?>">
                <div class="breadcrumbbox <?php echo esc_attr(get_theme_mod('peccular_innerpage_header_box_onload_effects','wow zoomIn')); ?>" data-wow-duration="1s">
                <div class='button'><?php peccular_lite_the_breadcrumb(); ?></div>
                <!--  <?php //peccular_lite_the_breadcrumb(); ?> -->
            </div>
        </div>
 <?php } ?>   
  <?php  
      echo '<img alt="about us" src="'.get_template_directory_uri().'/images/snakeline.png" class="snake" />';
   ?>
  <?php  
         echo '<img alt="about us" src="'.get_template_directory_uri().'/images/circle.png" class="circle" />';
      ?>
      <?php  
         echo '<img alt="about us" src="'.get_template_directory_uri().'/images/triangle.png" class="tri" />';
       ?>
        <?php  
           echo '<img alt="about us" src="'.get_template_directory_uri().'/images/snakeline.png" class="snake2" />';
          ?>

</header><!-- .entry-header --> 
<div class="peccular-innerpage-overlay"></div>
</div>
<main id="innerpage-box">
    <div class="<?php if(get_theme_mod('peccular_blog_page_width','Box Width') == 'Box Width'){ ?>container <?php } elseif(get_theme_mod('peccular_blog_page_width','Box Width') == 'Full Width'){ ?> container-fluid <?php }?>">
    <div class="inner_contentbox">
     <div class="row">

        <div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
           <div id="secondary" class="widget-area">
            <?php  dynamic_sidebar('peccular-blog-sidebar'); ?>
          </div>
        </div>

        <div id="blog-box" class="ht-blog-wrap innerpage-whitebox col-lg-8 col-md-6 col-sm-6 col-xs-12">
            <div class="row">
      <?php
            $current_page = max(1, get_query_var('paged'));
            $peccular_blog_cat_exclude = get_theme_mod('peccular_blog_categories');
            $peccular_blog_cat_exclude = explode(',', $peccular_blog_cat_exclude);
            $excerpt = get_theme_mod('peccular_blog_categories_settings');
            $args = array(
                'category__not_in' => $peccular_blog_cat_exclude,
                // 'page'=,
                'paged'=> $current_page,
            );
            $query = new WP_Query($args);
            if($query -> have_posts()):
                while($query -> have_posts()) : $query -> the_post();
                 $peccular_image = wp_get_attachment_image_src(get_post_thumbnail_id() , 'total-blog-thumb');
                 $img = (has_post_thumbnail())?esc_url($peccular_image[0]):get_template_directory_uri().'/images/default.png';
                 ?>
                 <div class="inner-blog-post wow zoomIn col-lg-6 col-md-12 col-sm-12 col-xs-12">
                   <div class="inner-blog-post wow zoomIn ">

                   <div class="peccular-box-area-S">               
                    <?php
                        if(get_theme_mod('blog_featured_img_on_off') != 'on' ){
                      ?>
                      <a href="<?php the_permalink(); ?>">
                        <div class="peccular-blog-imgbox">
                     <div class="ht-blog-thumbnail hover_color">
                      
                          <img class="inner-blog-img " src="<?php echo $img; ?>" alt="<?php the_title(); ?>" style="height: <?php echo esc_attr(get_theme_mod('peccular_blogpage_post_image_height','220')) ?>px;">                
                       
                    </div>
                    </div>
                     </a>
                    <?php } ?>

                      <div class="clearfix"></div>
                      
                      <div class="inner-blogpost-info">  
                        
                        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>                        
                     
                      <div class="clearfix"></div>

                      <?php if (get_theme_mod('blog_page_excerpt_display',true) != false){ ?>
                           <div class="inner-blog-excerpt">
                                <?php $peccular_excerpt = get_the_excerpt(); echo esc_html( peccular_string_limit_words( $peccular_excerpt, esc_attr(get_theme_mod('peccular_blogpage_post_excerpt','15')) ) ); ?>

                          </div>
                      <?php } ?>                        
                      <?php
                        $blogbutton = get_theme_mod('blog_page_btn_txt', 'Read More'); 
                      ?>
                      <?php
                        if(get_theme_mod('blog_page_button_display') != 'on' ){
                      ?>  
                          <div class="blog-page-btn">
                            <a href="<?php the_permalink(); ?>" target="_blank">.....      
                             <?php echo ($blogbutton );  ?>
                            </a>
                        </div>
                          <?php } ?>                    

                   <div class="clearfix"></div>
                 </div>
                 <!-- <?php //if (get_theme_mod('peccular_show_category',true) != false){ ?>
                        <div class="blog-category"> 
                          <span><i class="fa fa-file-o" aria-hidden="true"></i><?php //foreach((get_the_category()) as $category) { echo $category->cat_name . ' , '; } ?></span>
                        </div>
                      <?php //}?>
                      <?php //if (get_theme_mod('peccular_show_tags',false) != false){ ?>
                          <div class="blog-tags">
                            <i class="fa fa-tags" aria-hidden="true"></i>
                            <?php
                                  //if( $tags = get_the_tags() ) {
                                    //foreach( $tags as $content_tag ) {
                                      //$sep = ( $content_tag === end( $tags ) ) ? '' : ' ';
                                      //echo '<a href="' . esc_url(get_term_link( $content_tag, $content_tag->taxonomy )) . '" class="ml-2 mb-2">' . esc_html($content_tag->name) . '</a>' . esc_html($sep);
                                    //}
                                  //} ?>
              
                            </div>
                      <?php //}?>    -->     
                   <div class="blog-info-area"> 

                         <?php if (get_theme_mod('peccular_show_author',true) != false || get_theme_mod('peccular_show_time',true) != false || get_theme_mod('peccular_show_comments',true) != false){ ?>
                            <ul class="metabox"> 

                              <?php if (get_theme_mod('peccular_show_date',true) != false){ ?>
                                <li class="blog-date"> <i class="fa fa-calendar" aria-hidden="true"></i> <?php echo get_the_date( 'M j, Y' ); ?></li>
                                  <div class="mid-border"></div>
                               <?php }?>

                              <?php if (get_theme_mod('peccular_show_author',false) != false){ ?>
                               <li class="blog-author"><!-- <i class="fa fa-user" aria-hidden="true"></i> --> By <?php echo get_the_author(); ?> 
                              </li>
                              <?php }?> 
                              <?php if (get_theme_mod('peccular_show_comments',true) != false){ ?>
                               <li class="blog-comment"><i class="fa fa-comment-o" aria-hidden="true"></i>  <?php echo get_comments_number(); ?> Comments
                              </li>
                              <?php }?>                             
                                                    
                               <div class="clearfix"></div>
                            </ul>
                          <?php }?>                         
                        </div>  

               
                   <div class="clearfix"></div> 
                   
           </div>
           </div>
                          <script>
                        jQuery.noConflict();
                        $(function(){
                          function innerblogpostHeight(){
                            var ht = 0;
                            $('.page-template-blog-template .inner-blogpost-info').each(function(i){
                              var tHt = $(this).height();
                              if(ht<tHt){
                                ht=tHt;
                              }
                            });
                            $('.page-template-blog-template .inner-blogpost-info').height(ht+'px');
                          }
                          innerblogpostHeight();
                        });
                        $( window ).resize(function(){
                          innerblogpostHeight();
                        });
                      </script>
                   </div> 
                   <?php
               endwhile;
            endif;
            wp_reset_postdata();
            ?>
          </div>
            <div class="clearfix"></div>

            </div>


    <div class="clearfix"></div>
    
    <div class="pagingation">
        <?php lzGetPagination($query);?>
    </div>
     <div class="clearfix"></div>
    </div>
            <div class="clearfix"></div>
    </div>
  </div>
</main><!-- #main -->
<?php get_footer(); ?>
