<div class="container related-posts p-0">
  <div class="row">
    <div class="col-sm-12">
      <h4 class="title_single"><?php _e('Related posts', 'liosa'); ?></h4>
    </div>
    <?php
    $numbercountpagesingle  = ot_get_option('content_post_number_related', false);
    $orig_post = $post;
    global $post;
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
      $tag_ids = array();
      foreach ($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
      $args = array(
        'tag__in' => $tag_ids,
        'post__not_in' => array($post->ID),
        'posts_per_page' =>  $numbercountpagesingle,
        'ignore_sticky_posts' => 1
      );
      $my_query = new wp_query($args);
      while ($my_query->have_posts()) {
        $my_query->the_post();
    ?>
        <div class="col-6 col-md-3">
          <div class="related-item posts-lists">
            <a href="<?php the_permalink(); ?>">
              <div class="rel-thumbnail">
                <a href="<?php the_permalink(); ?>">
                  <?php the_post_thumbnail('thumb5'); ?>
                </a>
              </div>
              <figcaption>
                <?php the_title() ?>
                <span class="post-time">
                  <?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' پیش'; ?>
                </span>
              </figcaption>
            </a>
          </div>
        </div>
    <?php }
    }
    $post = $orig_post;
    wp_reset_query();
    ?>
  </div>
</div>