<div class="container archive__page">
    <div class="row">
        <aside class=" d-none d-lg-block">
            <div class="nav">
                <ul class="stick-menu">
                    <li class="stick-menu__item stick-logo">
                        <a href="<?php echo get_home_url(); ?>" title="<?php echo bloginfo('name'); ?>">
                            <?php echo \Elementor\Group_Control_Image_Size::get_attachment_image_html( $settings, 'thumbnail', 'image_logo' ); ?>
                        </a>
                    </li>
                    <li class="stick-menu__item search-bt">
                        <a href="#search">
                            <i class="fal fa-search"></i>
                        </a>
                    </li>
                    <li class="stick-menu__item">
                    <a class="user-login-but btn-login" onclick="document.getElementById('id01').style.display='block'">
                        <i class="fal fa-user-circle"></i>
                    </a>
                    </li>
                </ul>
            </div>
        </aside>
        <div class="min-contant-list main-content">
            <div>
                <header class="archive-header">
                    <div class="breadcrumb_vid">
                        <div class="row">
                            <ul class="col-9">
                                <div class="breadcrumb_dimag">
                                    <?php get_breadcrumb(); ?>
                                </div>
                            </ul>
                            <div class="breadcrumbs__icons col-3">
                                <a href="<?php echo $settings['website_link']['url'] ?>">
                                    <i class="fal fa-rss-square"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="archive-header__sep"></div>
                    <div class="media-header-vid">
                        <div class="row">
                            <div class="col-2">
                                <?php
                                if ('yes' === $settings['Iconlayoutvidshow']) {
                                    \Elementor\Icons_Manager::render_icon($settings['Iconlayoutvid'], ['aria-hidden' => 'true']);
                                } else {
                                    echo '<i class="fal fa-play"></i>';
                                }
                                ?>
                            </div>
                            <div class="media-header__content col-10">
                                <h1><?php echo $settings['title']; ?></h1>
                            </div>
                        </div>
                    </div>
                    <div class="archive-header__sep"></div>
                    <div class="category">
                        <div class="category__vol">
                            <span>
                                <?php
                                if ($settings['cat_id_lio']) {
                                    $cat_id_lio = $settings['cat_id_lio'];
                                    $category = get_category($cat_id_lio);
                                    $count = $category->category_count;
                                    echo $count;
                                }
                      
                                ?>
                            </span>
                            <span>مطلب موجود میباشد.</span>
                        </div>
                    </div>
                </header>
                <section class="masonry-gallery">
                    <div class="topics__content main">
                        <section class="topics-gallery list_vide root">
                            <div class="masonry-gallery-wid">
                                <?php
                                while ($all_posts->have_posts()) :
                                    $all_posts->the_post();
                        
                                        
                                ?>
                                <div class="item_masonry">
                                    <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', 'leora'); ?>" title="<?php _e('Image not found', 'leora'); ?>">
                                                <?php } 
                                            ?>
                                            </a>
                                            <span class="icon_type_wid">
                                                <?php
                                                if ('yes' === $settings['Iconlayoutvidshow']) {
                                                    \Elementor\Icons_Manager::render_icon($settings['Iconlayoutvid'], ['aria-hidden' => 'true']);
                                                } else {
                                                    echo '<i class="fal fa-play"></i>';
                                                }
                                                ?>
                                            </span>
                                            <?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="masonry-gallery__description">
                                        <?php
                                            $excerpt = get_the_excerpt();
                                            $excerpt = substr($excerpt, 0, 200);
                                            $result = substr($excerpt, 0, strrpos($excerpt, ' '));
                                            echo $result , ' ... ';
                                        ?>
                                        </div>
                                        <div class="item__details">
                                            <?php
                                                $avatar_name  = ot_get_option('avatar_name', false);
                                                if ($avatar_name  == 'on') :
                                            ?>
                                            <div class="user-profile-stat-wrapper">
                                                <?php echo get_avatar(get_the_author_meta('ID'), 96); ?>
                                                <span class="item__details--author"><?php the_author(); ?></span>
                                            </div>
                                            <?php endif; ?>
                                            <time class="item__details--date" style="float:<?php if ($avatar_name  == 'off'){ echo 'right'; }?>"><?php do_action('type_article'); ?> <i class="fal fa-clock"></i><?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' پیش'; ?></time>
                                        </div>
                                    </div>
                                </div>
                                <?php endwhile; ?>

                            </div>
                                       <?php                     
                            if (!empty($settings['grid_pagination'])) {
                                ?>
                                <div class="pagination root" style="width: 100%;">
                                    <?php
                                    $big = 999999999;
                                    $totalpages = $all_posts->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>', 'leora'),
                                    'next_text'          => __('<i class="fa fa-chevron-left" aria-hidden="true"></i>', 'leora'),
                                    'screen_reader_text' => __('A', 'leora')
                                    );
                                    $pagination = paginate_links($paginate_args);
                                    ?>
                                    <nav class="pagenumbers">
                                    <?php echo $pagination; ?>
                                    </nav>
                                </div>
                                <?php
                            }
                                ?>
                    </div>
            </div>
            </section>
        </div>
    </div>
</div>
</div>

