<div class="container main-content">
  <div class="module-title">
    <div class="row">
      <style>
        .module-title h2.color_custom {
          background-color: <?php echo $settings['title_color_2113']; ?>;
        }

        .module-title__btn,
        .module-title__sep.sl_th {
          border-color: <?php echo $settings['title_color_2112']; ?>
        }
      </style>
      <div class="col-12">
        <h2 class="color_custom"><span style="color:<?php echo $settings['title_color_1one']; ?>"><?php echo $settings['title']; ?></span></h2>
        <span class="module-title__sep sl_th"></span>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-12 col-lg-9 content">
      <div class="topics__content main">
        <section class="topics-gallery root">
          <div class="row">
            <?php
            while ($query->have_posts()) :
              $query->the_post();
            ?>
              <div class="col-12 col-sm-6 col-md-4 col-lg-3">
                <div class="topics-gallery__item">
                  <div class="image">
                    <div class="image__mask"></div>
                    <a href="<?php the_permalink(); ?>">
                      <?php
                      if (has_post_thumbnail()) {
                        the_post_thumbnail(array(200, 200), array('alt' => '' . get_the_title(), 'title' => '' . get_the_title() . ''));
                      } else { ?>
                        <img style="object-fit: cover;" src="<?php print(get_template_directory_uri()); ?>/assets/images/thumb.gif" width="200" height="200" alt="<?php _e('Image not found', 'liosa'); ?>" title="<?php _e('Image not found', 'liosa'); ?>">
                      <?php } ?>
                    </a>
                    <?php $category = get_the_category(); ?>
                    <a href="" title="<?php echo $category[0]->cat_name; ?>" class="image__badge">
                      <?php echo $category[0]->cat_name; ?>
                    </a>
                    <span class="image__fav">
                      <span class="popularity">
                        <span class="popularity__likes">
                          <i class="fal fa-heart"></i>
                          <span class="popularity__likes--num"></span>
                        </span>
                        <span class="popularity__time-to-read">
                          <?php if (info_content_get_meta('info_content_version')) { ?>
                            <i class="fal fa-stopwatch"></i>
                            <span class="popularity__minutes-read"><?php echo info_content_get_meta('info_content_version'); ?> مطالعه </span>
                          <?php } ?>
                        </span>
                      </span>
                    </span>
                  </div>
                  <a href="<?php the_permalink(); ?>" class="topics-gallery__item__title">
                    <?php the_title(); ?>
                  </a>
                  <div class="item__details">
                    <div class="user-profile-stat-wrapper">
                      <?php echo get_avatar(get_the_author_meta('ID'), 32); ?>
                      <span class="item__details--author"><?php the_author(); ?></span>
                    </div>
                    <time class="item__details--date"><i class="fal fa-clock"></i><?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' پیش'; ?></time>
                  </div>
                </div>
              </div>
            <?php endwhile;
            if (!empty($settings['grid_pagination'])) {
            ?>
              <div class="pagination root" style="width: 100%;">
                <?php
                $big = 999999999;
                $totalpages = $query->max_num_pages;
                $current = max(1, $paged);
                $paginate_args = array(
                  'base'      => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
                  'format'    => '?paged=%#%',
                  'current'   => $current,
                  'total'     => $totalpages,
                  'show_all'  => false,
                  'end_size'  => 1,
                  'mid_size'  => 3,
                  'prev_next' => true,
                  'prev_text'          => __('<i class="fa fa-chevron-right" aria-hidden="true"></i>', 'liosa'),
                  'next_text'          => __('<i class="fa fa-chevron-left" aria-hidden="true"></i>', 'liosa'),
                  'screen_reader_text' => __('A', 'liosa')
                );
                $pagination = paginate_links($paginate_args);
                ?>
                <nav class="pagenumbers">
                  <?php echo $pagination; ?>
                </nav>
              </div>
            <?php
            }
            ?>
          </div>
        </section>
      </div>
    </div>
    <?php get_sidebar('page'); ?>
  </div>
</div>