<?php $at_hpblogtitle = get_theme_mod( 'at_setting__hpblogtitle', esc_html__( 'From The Blog', 'motivate' ) );
$at_blogbutton = get_theme_mod('at_setting__blogbutton', esc_html__("More from the Blog", "motivate"));
$at_blogurl = get_theme_mod('at_setting__blogurl', esc_html__("/blog", "motivate")); 
$at_blognb = get_theme_mod('at_setting__blogpostnb', esc_html__("6", "motivate"));?>
<div id="at-blog-block" class="at-bloglist">
  <div class="at-container">

    <?php if ( !empty($at_hpblogtitle) ) : ?>
      <h3 class="at-bloglist__title"><?php echo esc_html( $at_hpblogtitle ); ?></h3>
    <?php endif; ?> 

    <?php $args=array(
    'posts_per_page'=> $at_blognb,
    'ignore_sticky_posts'=>1
    );

    $my_query = new wp_query( $args );
    
    if( $my_query->have_posts() ) : ?>
    
    <ul>

    <?php while( $my_query->have_posts() ) {
      $my_query->the_post();?>
        
    <li>
      <div class="at-bloglist__post">
      <a class="at-bloglist__link" href="<?php the_permalink()?>" rel="bookmark" style="display: block"></a>
      <?php if ( has_post_thumbnail() ) : ?>
         <div class="at-bloglist__postthumb">
          <a href="<?php the_permalink(); ?>">
            <?php the_post_thumbnail('motivate-hpblog'); ?>
          </a>
        </div>
      <?php endif; ?>
      <div class="at-bloglist__contentwrap <?php if ( true == get_theme_mod( 'at_setting__postsshare_archive', true ) ) echo 'at-bloglist__sm' ?>" >
        <a class="at-bloglist__link" href="<?php the_permalink()?>" rel="bookmark" style="display: block"></a>
        <h4 class="at-bloglist__posttitle">
          <a href="<?php the_permalink()?>" rel="bookmark"><?php the_title(); ?></a>
        </h4>
        <div class="at-bloglist__excerpt">
          <?php the_excerpt(); ?>
        </div>
        
      </div>
      <ul class="at-post__meta">
        <li><?php the_date(); ?></li>  
      </ul>
      
       <?php if ( true == get_theme_mod( 'at_setting__postsshare_archive', true ) ) : ?>
        <div class="at-post__metaf">
          <?php get_template_part( 'single', 'socialshare' ); ?>
        </div>
      <?php endif; ?>

      </div>
    </li>

    <?php } ?>
    </ul>

<?php endif; ?>

    <?php if ( ($at_blogbutton) || ($at_blogurl)  ) : ?>
        <a class="at-blog__blockbutton" href="<?php echo esc_url( $at_blogurl ); ?>"><span><?php echo esc_html( $at_blogbutton) ; ?></span></a>
      <?php endif; ?>
  </div>
</div>